source: cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/api/ddm-base.js.html @ 5259

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/api/ddm-base.js.html@5259
Revision 5259, 34.8 KB checked in by domlowe, 11 years ago (diff)

adding yui javascript

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4        <title>API: dd   ddm-base.js  (YUI Library)</title>
5        <link rel="stylesheet" type="text/css" href="assets/api.css">
6    <script type="text/javascript" src="assets/api-js"></script>
7    <script type="text/javascript" src="assets/ac-js"></script>
8</head>
9
10<body id="yahoo-com">
11
12<div id="doc3" class="yui-t2">
13
14        <div id="hd">
15        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
16        <h3>dd&nbsp; <span class="subtitle">3.0.0pr1</span></h3>
17        <p>
18        <a href="./index.html">Yahoo! UI Library</a> 
19            &gt; <a href="./module_dd.html">dd</a>
20               
21                 &gt; ddm-base.js (source view)
22            </p>
23
24
25        </div>
26
27        <div id="bd">
28                <div id="yui-main">
29                        <div class="yui-b">
30            <form name="yui-classopts-form">
31    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
32    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
33    <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
34            </form>
35
36                    <div id="srcout">
37                        <style>
38                            #doc3 #classopts { display:none; }
39                        </style>
40<div class="highlight" ><pre>    <span class="c">/**</span>
41<span class="c">     * Provides the base Drag Drop Manger required for making a Node draggable.</span>
42<span class="c">     * @module dd</span>
43<span class="c">     * @submodule dd-ddm-base</span>
44<span class="c">     */</span>     
45     <span class="c">/**</span>
46<span class="c">     * Provides the base Drag Drop Manger required for making a Node draggable.</span>
47<span class="c">     * @class DDM</span>
48<span class="c">     * @extends Base</span>
49<span class="c">     * @constructor</span>
50<span class="c">     */</span>
51   
52    <span class="k">var</span> <span class="nx">DDMBase</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
53        <span class="c">//debugger;</span>
54<span class="c"></span>        <span class="nx">DDMBase</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
55    <span class="o">};</span>
56
57    <span class="nx">DDMBase</span><span class="o">.</span><span class="nx">NAME</span> <span class="o">=</span> <span class="s1">&#39;DragDropMgr&#39;</span><span class="o">;</span>
58
59    <span class="nx">DDMBase</span><span class="o">.</span><span class="nx">ATTRS</span> <span class="o">=</span> <span class="o">{</span>
60        <span class="c">/**</span>
61<span class="c">        * @attribute clickPixelThresh</span>
62<span class="c">        * @description The number of pixels to move to start a drag operation, default is 3.</span>
63<span class="c">        * @type Number</span>
64<span class="c">        */</span>
65        <span class="nx">clickPixelThresh</span><span class="o">:</span> <span class="o">{</span>
66            <span class="nx">value</span><span class="o">:</span> <span class="m">3</span>
67        <span class="o">},</span>
68        <span class="c">/**</span>
69<span class="c">        * @attribute clickTimeThresh</span>
70<span class="c">        * @description The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.</span>
71<span class="c">        * @type Number</span>
72<span class="c">        */</span>       
73        <span class="nx">clickTimeThresh</span><span class="o">:</span> <span class="o">{</span>
74            <span class="nx">value</span><span class="o">:</span> <span class="m">1000</span>
75        <span class="o">},</span>
76        <span class="c">/**</span>
77<span class="c">        * @attribute dragMode</span>
78<span class="c">        * @description This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of all future Drag instances. </span>
79<span class="c">        * @type String</span>
80<span class="c">        */</span>       
81        <span class="nx">dragMode</span><span class="o">:</span> <span class="o">{</span>
82            <span class="nx">value</span><span class="o">:</span> <span class="s1">&#39;point&#39;</span><span class="o">,</span>
83            <span class="nx">set</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">mode</span><span class="o">)</span> <span class="o">{</span>
84                <span class="k">this</span><span class="o">.</span><span class="nx">_setDragMode</span><span class="o">(</span><span class="nx">mode</span><span class="o">);</span>
85            <span class="o">}</span>           
86        <span class="o">}</span>
87
88    <span class="o">};</span>
89
90    <span class="nx">Y</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">DDMBase</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Base</span><span class="o">,</span> <span class="o">{</span>
91        <span class="c">/**</span>
92<span class="c">        * @private</span>
93<span class="c">        * @method _setDragMode</span>
94<span class="c">        * @description Handler for dragMode attribute setter.</span>
95<span class="c">        * @param String/Number The Number value or the String for the DragMode to default all future drag instances to.</span>
96<span class="c">        * @return Number The Mode to be set</span>
97<span class="c">        */</span>
98        <span class="nx">_setDragMode</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">mode</span><span class="o">)</span> <span class="o">{</span>
99            <span class="k">if</span> <span class="o">(</span><span class="nx">mode</span> <span class="o">===</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
100                <span class="nx">mode</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">DD</span><span class="o">.</span><span class="nx">DDM</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;dragMode&#39;</span><span class="o">);</span>
101            <span class="o">}</span>
102            <span class="nx">switch</span> <span class="o">(</span><span class="nx">mode</span><span class="o">)</span> <span class="o">{</span>
103                <span class="nx">case</span> <span class="m">1</span><span class="o">:</span>
104                <span class="nx">case</span> <span class="s1">&#39;intersect&#39;</span><span class="o">:</span>
105                    <span class="k">return</span> <span class="m">1</span><span class="o">;</span>
106                <span class="nx">case</span> <span class="m">2</span><span class="o">:</span>
107                <span class="nx">case</span> <span class="s1">&#39;strict&#39;</span><span class="o">:</span>
108                    <span class="k">return</span> <span class="m">2</span><span class="o">;</span>
109                <span class="nx">case</span> <span class="m">0</span><span class="o">:</span>
110                <span class="nx">case</span> <span class="s1">&#39;point&#39;</span><span class="o">:</span>
111                    <span class="k">return</span> <span class="m">0</span><span class="o">;</span>
112            <span class="o">}</span>
113            <span class="k">return</span> <span class="m">0</span><span class="o">;</span>       
114        <span class="o">},</span>
115        <span class="c">/**</span>
116<span class="c">        * @property CSS_PREFIX</span>
117<span class="c">        * @description The PREFIX to attach to all DD CSS class names</span>
118<span class="c">        * @type {String}</span>
119<span class="c">        */</span>
120        <span class="nx">CSS_PREFIX</span><span class="o">:</span> <span class="s1">&#39;yui-dd&#39;</span><span class="o">,</span>
121        <span class="nx">_activateTargets</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{},</span>       
122        <span class="c">/**</span>
123<span class="c">        * @private</span>
124<span class="c">        * @property _drags</span>
125<span class="c">        * @description Holder for all registered drag elements.</span>
126<span class="c">        * @type {Array}</span>
127<span class="c">        */</span>
128        <span class="nx">_drags</span><span class="o">:</span> <span class="o">[],</span>
129        <span class="c">/**</span>
130<span class="c">        * @property activeDrag</span>
131<span class="c">        * @description A reference to the currently active draggable object.</span>
132<span class="c">        * @type {Drag}</span>
133<span class="c">        */</span>
134        <span class="nx">activeDrag</span><span class="o">:</span> <span class="kc">false</span><span class="o">,</span>
135        <span class="c">/**</span>
136<span class="c">        * @private</span>
137<span class="c">        * @method _regDrag</span>
138<span class="c">        * @description Adds a reference to the drag object to the DDM._drags array, called in the constructor of Drag.</span>
139<span class="c">        * @param {Drag} d The Drag object</span>
140<span class="c">        */</span>
141        <span class="nx">_regDrag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">d</span><span class="o">)</span> <span class="o">{</span>
142            <span class="k">this</span><span class="o">.</span><span class="nx">_drags</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">_drags</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">d</span><span class="o">;</span>
143        <span class="o">},</span>
144        <span class="c">/**</span>
145<span class="c">        * @private</span>
146<span class="c">        * @method _unregDrag</span>
147<span class="c">        * @description Remove this drag object from the DDM._drags array.</span>
148<span class="c">        * @param {Drag} d The drag object.</span>
149<span class="c">        */</span>
150        <span class="nx">_unregDrag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">d</span><span class="o">)</span> <span class="o">{</span>
151            <span class="k">var</span> <span class="nx">tmp</span> <span class="o">=</span> <span class="o">[];</span>
152            <span class="nx">Y</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_drags</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">n</span><span class="o">,</span> <span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
153                <span class="k">if</span> <span class="o">(</span><span class="nx">n</span> <span class="o">!==</span> <span class="nx">d</span><span class="o">)</span> <span class="o">{</span>
154                    <span class="nx">tmp</span><span class="o">[</span><span class="nx">tmp</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">n</span><span class="o">;</span>
155                <span class="o">}</span>
156            <span class="o">});</span>
157            <span class="k">this</span><span class="o">.</span><span class="nx">_drags</span> <span class="o">=</span> <span class="nx">tmp</span><span class="o">;</span>
158        <span class="o">},</span>
159        <span class="c">/**</span>
160<span class="c">        * @private</span>
161<span class="c">        * @method _init</span>
162<span class="c">        * @description DDM&#39;s init method</span>
163<span class="c">        */</span>
164        <span class="nx">initializer</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
165            <span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;document&#39;</span><span class="o">).</span><span class="nx">on</span><span class="o">(</span><span class="s1">&#39;mousemove&#39;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_move</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
166            <span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;document&#39;</span><span class="o">).</span><span class="nx">on</span><span class="o">(</span><span class="s1">&#39;mouseup&#39;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_end</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
167            <span class="c">//Y.Event.Target.apply(this);</span>
168<span class="c"></span>        <span class="o">},</span>
169        <span class="c">/**</span>
170<span class="c">        * @private</span>
171<span class="c">        * @method _start</span>
172<span class="c">        * @description Internal method used by Drag to signal the start of a drag operation</span>
173<span class="c">        * @param {Number} x The x position of the drag element</span>
174<span class="c">        * @param {Number} y The y position of the drag element</span>
175<span class="c">        * @param {Number} w The width of the drag element</span>
176<span class="c">        * @param {Number} h The height of the drag element</span>
177<span class="c">        */</span>
178        <span class="nx">_start</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">x</span><span class="o">,</span> <span class="nx">y</span><span class="o">,</span> <span class="nx">w</span><span class="o">,</span> <span class="nx">h</span><span class="o">)</span> <span class="o">{</span>
179            <span class="k">this</span><span class="o">.</span><span class="nx">_startDrag</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
180        <span class="o">},</span>
181        <span class="c">/**</span>
182<span class="c">        * @private</span>
183<span class="c">        * @method _startDrag</span>
184<span class="c">        * @description Factory method to be overwritten by other DDM&#39;s</span>
185<span class="c">        * @param {Number} x The x position of the drag element</span>
186<span class="c">        * @param {Number} y The y position of the drag element</span>
187<span class="c">        * @param {Number} w The width of the drag element</span>
188<span class="c">        * @param {Number} h The height of the drag element</span>
189<span class="c">        */</span>
190        <span class="nx">_startDrag</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{},</span>
191        <span class="c">/**</span>
192<span class="c">        * @private</span>
193<span class="c">        * @method _endDrag</span>
194<span class="c">        * @description Factory method to be overwritten by other DDM&#39;s</span>
195<span class="c">        */</span>
196        <span class="nx">_endDrag</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{},</span>
197        <span class="nx">_dropMove</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{},</span>
198        <span class="c">/**</span>
199<span class="c">        * @private</span>
200<span class="c">        * @method _end</span>
201<span class="c">        * @description Internal method used by Drag to signal the end of a drag operation</span>
202<span class="c">        */</span>
203        <span class="nx">_end</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
204            <span class="c">//@TODO - Here we can get a (click - drag - click - release) interaction instead of a (mousedown - drag - mouseup - release) interaction</span>
205<span class="c"></span>            <span class="c">//Add as a config option??</span>
206<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">)</span> <span class="o">{</span>
207                <span class="k">this</span><span class="o">.</span><span class="nx">_endDrag</span><span class="o">();</span>
208                <span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">.</span><span class="nx">end</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">);</span>
209                <span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
210            <span class="o">}</span>
211        <span class="o">},</span>
212        <span class="c">/**</span>
213<span class="c">        * @method stopDrag</span>
214<span class="c">        * @description Method will forcefully stop a drag operation. For example calling this from inside an ESC keypress handler will stop this drag.</span>
215<span class="c">        * @return {Self}</span>
216<span class="c">        * @chainable</span>
217<span class="c">        */</span>       
218        <span class="nx">stopDrag</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
219            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">)</span> <span class="o">{</span>
220                <span class="k">this</span><span class="o">.</span><span class="nx">_end</span><span class="o">();</span>
221            <span class="o">}</span>
222            <span class="k">return</span> <span class="k">this</span><span class="o">;</span>
223        <span class="o">},</span>
224        <span class="c">/**</span>
225<span class="c">        * @private</span>
226<span class="c">        * @method _move</span>
227<span class="c">        * @description Internal listener for the mousemove DOM event to pass to the Drag&#39;s move method.</span>
228<span class="c">        * @param {Event} ev The Dom mousemove Event</span>
229<span class="c">        */</span>
230        <span class="nx">_move</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">ev</span><span class="o">)</span> <span class="o">{</span>
231            <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">)</span> <span class="o">{</span>
232                <span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">.</span><span class="nx">_move</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">activeDrag</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
233                <span class="k">this</span><span class="o">.</span><span class="nx">_dropMove</span><span class="o">();</span>
234            <span class="o">}</span>
235        <span class="o">},</span>
236        <span class="c">/**</span>
237<span class="c">        * @method setXY</span>
238<span class="c">        * @description A simple method to set the top and left position from offsets instead of page coordinates</span>
239<span class="c">        * @param {Object} node The node to set the position of </span>
240<span class="c">        * @param {Array} xy The Array of left/top position to be set.</span>
241<span class="c">        */</span>
242        <span class="nx">setXY</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">,</span> <span class="nx">xy</span><span class="o">)</span> <span class="o">{</span>
243            <span class="k">var</span> <span class="nx">t</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="s1">&#39;top&#39;</span><span class="o">),</span> <span class="m">10</span><span class="o">),</span>
244            <span class="nx">l</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">node</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="s1">&#39;left&#39;</span><span class="o">),</span> <span class="m">10</span><span class="o">),</span>
245            <span class="nx">pos</span> <span class="o">=</span> <span class="nx">node</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="s1">&#39;position&#39;</span><span class="o">);</span>
246
247            <span class="k">if</span> <span class="o">(</span><span class="nx">pos</span> <span class="o">===</span> <span class="s1">&#39;static&#39;</span><span class="o">)</span> <span class="o">{</span>
248                <span class="nx">node</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="s1">&#39;position&#39;</span><span class="o">,</span> <span class="s1">&#39;relative&#39;</span><span class="o">);</span>
249            <span class="o">}</span>
250
251            <span class="c">// in case of &#39;auto&#39;</span>
252<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">t</span><span class="o">))</span> <span class="o">{</span> <span class="nx">t</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="o">}</span>
253            <span class="k">if</span> <span class="o">(</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">l</span><span class="o">))</span> <span class="o">{</span> <span class="nx">l</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="o">}</span>
254           
255            <span class="nx">node</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="s1">&#39;top&#39;</span><span class="o">,</span> <span class="o">(</span><span class="nx">xy</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">+</span> <span class="nx">t</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;px&#39;</span><span class="o">);</span>
256            <span class="nx">node</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="s1">&#39;left&#39;</span><span class="o">,</span> <span class="o">(</span><span class="nx">xy</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">+</span> <span class="nx">l</span><span class="o">)</span> <span class="o">+</span> <span class="s1">&#39;px&#39;</span><span class="o">);</span>
257           
258        <span class="o">},</span>
259        <span class="c">/**</span>
260<span class="c">        * //TODO Private, rename??...</span>
261<span class="c">        * @private</span>
262<span class="c">        * @method cssSizestoObject</span>
263<span class="c">        * @description Helper method to use to set the gutter from the attribute setter.</span>
264<span class="c">        * @param {String} gutter CSS style string for gutter: &#39;5 0&#39; (sets top and bottom to 5px, left and right to 0px), &#39;1 2 3 4&#39; (top 1px, right 2px, bottom 3px, left 4px)</span>
265<span class="c">        * @return {Object} The gutter Object Literal.</span>
266<span class="c">        */</span>
267        <span class="nx">cssSizestoObject</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">gutter</span><span class="o">)</span> <span class="o">{</span>
268            <span class="k">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="nx">gutter</span><span class="o">.</span><span class="nx">split</span><span class="o">(</span><span class="s1">&#39; &#39;</span><span class="o">),</span>
269            <span class="nx">g</span> <span class="o">=</span> <span class="o">{</span>
270                <span class="nx">top</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
271                <span class="nx">bottom</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
272                <span class="nx">right</span><span class="o">:</span> <span class="m">0</span><span class="o">,</span>
273                <span class="nx">left</span><span class="o">:</span> <span class="m">0</span>
274            <span class="o">};</span>
275            <span class="k">if</span> <span class="o">(</span><span class="nx">p</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span>
276                <span class="nx">g</span><span class="o">.</span><span class="nx">top</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">0</span><span class="o">],</span> <span class="m">10</span><span class="o">);</span>
277                <span class="k">if</span> <span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">{</span>
278                    <span class="nx">g</span><span class="o">.</span><span class="nx">right</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">1</span><span class="o">],</span> <span class="m">10</span><span class="o">);</span>
279                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
280                    <span class="nx">g</span><span class="o">.</span><span class="nx">right</span> <span class="o">=</span> <span class="nx">g</span><span class="o">.</span><span class="nx">top</span><span class="o">;</span>
281                <span class="o">}</span>
282                <span class="k">if</span> <span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">2</span><span class="o">])</span> <span class="o">{</span>
283                    <span class="nx">g</span><span class="o">.</span><span class="nx">bottom</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">2</span><span class="o">],</span> <span class="m">10</span><span class="o">);</span>
284                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
285                    <span class="nx">g</span><span class="o">.</span><span class="nx">bottom</span> <span class="o">=</span> <span class="nx">g</span><span class="o">.</span><span class="nx">top</span><span class="o">;</span>
286                <span class="o">}</span>
287                <span class="k">if</span> <span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">3</span><span class="o">])</span> <span class="o">{</span>
288                    <span class="nx">g</span><span class="o">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">3</span><span class="o">],</span> <span class="m">10</span><span class="o">);</span>
289                <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">p</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">{</span>
290                    <span class="nx">g</span><span class="o">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">g</span><span class="o">.</span><span class="nx">right</span><span class="o">;</span>
291                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
292                    <span class="nx">g</span><span class="o">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">g</span><span class="o">.</span><span class="nx">top</span><span class="o">;</span>
293                <span class="o">}</span>
294            <span class="o">}</span>
295            <span class="k">return</span> <span class="nx">g</span><span class="o">;</span>
296        <span class="o">},</span>
297        <span class="c">/**</span>
298<span class="c">        * @method getDrag</span>
299<span class="c">        * @description Get a valid Drag instance back from a Node or a selector string, false otherwise</span>
300<span class="c">        * @param {String/Object} node The Node instance or Selector string to check for a valid Drag Object</span>
301<span class="c">        * @return {Object}</span>
302<span class="c">        */</span>
303        <span class="nx">getDrag</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">node</span><span class="o">)</span> <span class="o">{</span>
304            <span class="k">var</span> <span class="nx">drag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">,</span>
305                <span class="nx">n</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">node</span><span class="o">);</span>
306            <span class="k">if</span> <span class="o">(</span><span class="nx">n</span> <span class="k">instanceof</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Node</span><span class="o">)</span> <span class="o">{</span>
307                <span class="nx">Y</span><span class="o">.</span><span class="nx">each</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_drags</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">v</span><span class="o">,</span> <span class="nx">k</span><span class="o">)</span> <span class="o">{</span>
308                    <span class="k">if</span> <span class="o">(</span><span class="nx">n</span><span class="o">.</span><span class="nx">compareTo</span><span class="o">(</span><span class="nx">v</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="s1">&#39;node&#39;</span><span class="o">)))</span> <span class="o">{</span>
309                        <span class="nx">drag</span> <span class="o">=</span> <span class="nx">v</span><span class="o">;</span>
310                    <span class="o">}</span>
311                <span class="o">});</span>
312            <span class="o">}</span>
313            <span class="k">return</span> <span class="nx">drag</span><span class="o">;</span>
314        <span class="o">}</span>
315    <span class="o">});</span>
316
317    <span class="nx">Y</span><span class="o">.</span><span class="nx">namespace</span><span class="o">(</span><span class="s1">&#39;DD&#39;</span><span class="o">);</span>
318    <span class="nx">Y</span><span class="o">.</span><span class="nx">DD</span><span class="o">.</span><span class="nx">DDM</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">DDMBase</span><span class="o">();</span>
319</pre></div>
320                    </div>
321                        </div>
322                </div>
323                <div class="yui-b">
324            <div class="nav">
325
326                    <div class="module">
327                        <h4>Modules</h4>
328                        <ul class="content">
329
330                                <li class=""><a href="module_anim.html">anim</a></li>
331
332                                <li class=""><a href="module_attribute.html">attribute</a></li>
333
334                                <li class=""><a href="module_base.html">base</a></li>
335
336                                <li class=""><a href="module_cookie.html">cookie</a></li>
337
338                                <li class="selected"><a href="module_dd.html">dd</a></li>
339
340                                <li class=""><a href="module_dd-plugin.html">dd-plugin</a></li>
341
342                                <li class=""><a href="module_dom.html">dom</a></li>
343
344                                <li class=""><a href="module_dump.html">dump</a></li>
345
346                                <li class=""><a href="module_event.html">event</a></li>
347
348                                <li class=""><a href="module_io.html">io</a></li>
349
350                                <li class=""><a href="module_json.html">json</a></li>
351
352                                <li class=""><a href="module_node.html">node</a></li>
353
354                                <li class=""><a href="module_oop.html">oop</a></li>
355
356                                <li class=""><a href="module_queue.html">queue</a></li>
357
358                                <li class=""><a href="module_substitute.html">substitute</a></li>
359
360                                <li class=""><a href="module_yui.html">yui</a></li>
361                        </ul>
362                    </div>
363
364                    <div class="module">
365                        <h4>Classes</h4>
366                        <ul class="content">
367                                <li class=""><a href="DDM.html">DDM</a></li>
368                                <li class=""><a href="Drag.html">Drag</a></li>
369                                <li class=""><a href="DragConstained.html">DragConstained</a></li>
370                                <li class=""><a href="Drop.html">Drop</a></li>
371                                <li class=""><a href="Proxy.html">Proxy</a></li>
372                        </ul>
373                    </div>
374
375                    <div class="module">
376                        <h4>Files</h4>
377                        <ul class="content">       
378                                <li class=""><a href="constrain.js.html">constrain.js</a></li>
379                                <li class="selected"><a href="ddm-base.js.html">ddm-base.js</a></li>
380                                <li class=""><a href="ddm-drop.js.html">ddm-drop.js</a></li>
381                                <li class=""><a href="ddm.js.html">ddm.js</a></li>
382                                <li class=""><a href="drag.js.html">drag.js</a></li>
383                                <li class=""><a href="drop.js.html">drop.js</a></li>
384                                <li class=""><a href="proxy.js.html">proxy.js</a></li>
385                        </ul>
386                    </div>
387
388
389
390
391
392            </div>
393                </div>
394        </div>
395        <div id="ft">
396        <hr />
397        Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
398        </div>
399</div>
400</body>
401</html>
Note: See TracBrowser for help on using the repository browser.