source: cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/examples/dd/constrained-drag.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/examples/dd/constrained-drag.html@5259
Revision 5259, 13.7 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>YUI Library Examples: Drag &amp; Drop Utility: Drag Constrained to a Region</title>
5    <meta http-equiv="content-type" content="text/html; charset=utf-8">
6        <link rel="stylesheet" type="text/css" href="../../assets/yui.css" >
7
8<style>
9    /*Supplemental CSS for the YUI distribution*/
10    #custom-doc { width: 95%; min-width: 950px; }
11    #pagetitle {background-image: url(../../assets/bg_hd.gif);}
12    #pagetitle h1 {background-image: url(../../assets/title_h_bg.gif);}
13</style>
14
15<link rel="stylesheet" type="text/css" href="../../assets/dpSyntaxHighlighter.css">
16
17<!--there is no custom header content for this example-->
18
19<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" />
20<script type="text/javascript" src="../../build/yui/yui-min.js"></script>
21
22</head>
23<body id="yahoo-com" class=" yui-skin-sam">
24<div id="custom-doc" class="yui-t2">
25<div id="hd">
26        <div id="ygunav">
27                <p>
28            <em>
29                <a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> 
30            </em>
31                </p>
32                <form action="http://search.yahoo.com/search" id="sitesearchform">
33            <input name="vs" type="hidden" value="developer.yahoo.com">
34            <input name="vs" type="hidden" value="yuiblog.com">
35                    <div id="sitesearch">
36                        <label for="searchinput">Site Search (YDN &amp; YUIBlog): </label>
37                            <input type="text" id="searchinput" name="p">
38                            <input type="submit" value="Search" id="searchsubmit" class="ygbt">
39                    </div>
40                </form>
41    </div>
42        <div id="ygma"><a href="../../"><img src="../../assets/logo.gif"  border="0" width="200" height="93"></a></div>
43        <div id="pagetitle"><h1>YUI Library Examples: Drag &amp; Drop Utility: Drag Constrained to a Region</h1></div>
44</div>
45<div id="bd">
46
47        <div id="bar-note"><p><strong>Note:</strong> This is YUI 3.x. Looking for <a href="http://developer.yahoo.com/yui/">YUI 2.x</a>?</p></div>
48
49        <div id="yui-main">
50                <div class="yui-b">
51                  <div class="yui-ge">
52                          <div class="yui-u first example" id="main">
53
54        <h2>Drag &amp; Drop Utility: Drag Constrained to a Region</h2>
55
56        <div id="example" class="promo">
57        <p>
58        <p>This example shows how to constrain a draggable Node to another Nodes region.</p>
59        </p>   
60
61        <div class="module example-container ">
62                        <div class="hd exampleHd">
63                        <p class="newWindowButton yui-skin-sam">
64                <a href="constrained-drag_clean.html" target="_blank">View example in new window.</a>
65            </p>
66                </div>          <div id="example-canvas" class="bd">
67
68               
69        <!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
70       
71        <style>
72.dd-demo {
73    position: relative;
74    text-align: center;
75    color: #fff;
76    cursor: move;
77    height: 60px;
78    width: 60px;
79    padding: 0;
80    margin: 0;
81}
82
83.dd-demo div {
84    border: 1px solid black;
85    height: 58px;
86    width: 58px;
87}
88
89#dd-demo-canvas1 {
90    padding: 55px;
91    background-color: #004C6D;
92    border: 1px solid black;
93}
94#dd-demo-canvas2 {
95    padding: 25px;
96    background-color: #CDCDCD;
97    border: 1px solid black;
98}
99#dd-demo-canvas3 {
100    padding: 15px;
101    background-color: #8DD5E7;
102    border: 1px solid black;
103}
104
105#dd-demo-1 { 
106    background-color: #8DD5E7;
107    top:5px;
108    left:5px;
109    color: #000;
110}
111
112#dd-demo-2 { 
113    background-color: #CDCDCD;
114    top:50px;
115    left:100px;
116    color: #000;
117}
118
119#dd-demo-3 {
120    background-color: #004C6D;
121    top:-100px;
122    left:200px;
123}
124
125</style>
126
127<div id="dd-demo-canvas1">
128    <div id="dd-demo-canvas2">
129        <div id="dd-demo-canvas3">
130            <div id="dd-demo-1" class="dd-demo"><div>1</div></div>
131            <div id="dd-demo-2" class="dd-demo"><div>2</div></div>
132            <div id="dd-demo-3" class="dd-demo"><div>3</div></div>
133        </div>
134    </div>
135</div>
136
137<script>
138YUI({base:"../../build/", timeout: 10000}).use('dd-constrain', function(Y) {
139    var dd1 = new Y.DD.Drag({
140        node: '#dd-demo-1',
141        constrain2node: '#dd-demo-canvas3'
142    });
143
144    var dd2 = new Y.DD.Drag({
145        node: '#dd-demo-2',
146        constrain2node: '#dd-demo-canvas2'
147    });
148
149    var dd3 = new Y.DD.Drag({
150        node: '#dd-demo-3',
151        constrain2node: '#dd-demo-canvas1'
152    });
153});
154</script>
155       
156        <!--END SOURCE CODE FOR EXAMPLE =============================== -->
157       
158               
159                </div>
160        </div>                 
161        </div>
162               
163        <h3>Setting up the Node</h3>
164<p>First we need to create the HTML structure used in this example.</p>
165<textarea name="code" class="HTML">
166<div id="dd-demo-canvas1">
167    <div id="dd-demo-canvas2">
168        <div id="dd-demo-canvas3">
169            <div id="dd-demo-1" class="dd-demo"><div>1</div></div>
170            <div id="dd-demo-2" class="dd-demo"><div>2</div></div>
171            <div id="dd-demo-3" class="dd-demo"><div>3</div></div>
172        </div>
173    </div>
174</div>
175</textarea>
176<p>Now we give the Nodes some CSS to make them visible.</p>
177<textarea name="code" class="CSS">
178.dd-demo {
179    position: relative;
180    text-align: center;
181    color: #fff;
182    cursor: move;
183    height: 60px;
184    width: 60px;
185    padding: 0;
186    margin: 0;
187}
188
189.dd-demo div {
190    border: 1px solid black;
191    height: 58px;
192    width: 58px;
193}
194
195#dd-demo-canvas1 {
196    padding: 55px;
197    background-color: #004C6D;
198    border: 1px solid black;
199}
200#dd-demo-canvas2 {
201    padding: 25px;
202    background-color: #CDCDCD;
203    border: 1px solid black;
204}
205#dd-demo-canvas3 {
206    padding: 15px;
207    background-color: #8DD5E7;
208    border: 1px solid black;
209}
210
211#dd-demo-1 {
212    background-color: #8DD5E7;
213    top:5px;
214    left:5px;
215    color: #000;
216}
217
218#dd-demo-2 {
219    background-color: #CDCDCD;
220    top:50px;
221    left:100px;
222    color: #000;
223}
224
225#dd-demo-3 {
226    background-color: #004C6D;
227    top:-100px;
228    left:200px;
229}
230</textarea>
231
232<h3>Setting up the YUI Instance</h3>
233<p>Now we need to create our YUI instance and tell it to load the <code>dd-constrain</code> module (that will load the dd-ddm and dd-drag modules too).</p>
234<textarea name="code" class="JScript">
235YUI().use('dd-constrain');
236</textarea>
237
238<h3>Making the Nodes draggable</h3>
239<p>Now that we have a YUI instance with the <code>dd-constrain</code> module, we need to instantiate the <code>Drag</code> instance on the Nodes.</p>
240<textarea name="code" class="JScript">
241YUI().use('dd-constrain', function(Y) {
242    var dd1 = new Y.DD.Drag({
243        node: '#dd-demo-1'
244    });
245
246    var dd2 = new Y.DD.Drag({
247        node: '#dd-demo-2'
248    });
249
250    var dd3 = new Y.DD.Drag({
251        node: '#dd-demo-3'
252    });
253});
254</textarea>
255
256<h3>Constrain the Nodes to other Nodes</h3>
257<p>Now that we have the Nodes draggable, we need to constrain them. We can do this by passing another config option called <code>constrain2node</code> and giving it a selector string of the Node we want to constrain to.</p>
258<textarea name="code" class="JScript">
259YUI().use('dd-constrain', function(Y) {
260    var dd1 = new Y.DD.Drag({
261        node: '#dd-demo-1',
262        constrain2node: '#dd-demo-canvas3'
263    });
264
265    var dd2 = new Y.DD.Drag({
266        node: '#dd-demo-2',
267        constrain2node: '#dd-demo-canvas2'
268    });
269
270    var dd3 = new Y.DD.Drag({
271        node: '#dd-demo-3',
272        constrain2node: '#dd-demo-canvas1'
273    });
274});
275</textarea>
276                                </div>
277                                <div class="yui-u sidebar">
278                                       
279                               
280                                        <div id="examples" class="mod box4">
281                        <div class="hd">
282                                                <h4>
283    Drag &amp; Drop Utility Examples:</h4>
284                        </div>
285                                                <div class="bd">
286                                                        <ul>
287                                                                <li><a href='../dd/simple-drag.html'>Simple Drag</a></li><li><a href='../dd/drag-plugin.html'>Drag Node Plugin</a></li><li><a href='../dd/proxy-drag.html'>Proxy Drag</a></li><li class='selected'><a href='../dd/constrained-drag.html'>Drag Constrained to a Region</a></li><li><a href='../dd/groups-drag.html'>Interaction Groups</a></li><li><a href='../dd/shim-drag.html'>Using the Drag Shim</a></li><li><a href='../dd/list-drag.html'>List reorder w/Bubbling</a></li><li><a href='../dd/portal-drag.html'>Portal Style Example</a></li><li><a href='../dd/anim-drop.html'>Animated Drop Targets</a></li><li><a href='../dd/drop-code.html'>Drop Based Coding</a></li>                                                        </ul>
288                                                </div>
289                                        </div>
290                                       
291                                        <div class="mod box4">
292                        <div class="hd">
293                                                <h4>More Drag &amp; Drop Utility Resources:</h4>
294                        </div>
295                        <div class="bd">
296                                                <ul>
297                                                        <!-- <li><a href="http://developer.yahoo.com/yui/dd/">User's Guide</a> (external)</li> -->
298                                                <li><a href="../../api/module_dd.html">API Documentation</a></li>
299</ul>
300                        </div>
301                                        </div>
302                          </div>
303                </div>
304               
305                </div>
306        </div>
307
308
309<div class="yui-b toc3" id="tocWrapper">
310<!-- TABLE OF CONTENTS -->
311<div id="toc">
312       
313<ul>
314<li class="sect first">YUI 3.x Project</li><li class="item"><a title="The Yahoo! User Interface (YUI) Library, 3.x Branch, " href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site (external)</a></li><li class="item"><a title="Examples of every YUI utility and control in action" href="../../examples/">YUI 3 Examples</a></li><li class="item"><a title="Instantly searchable API documentation for the entire YUI library." href="../../api/">YUI 3 API Docs</a></li><li class="item"><a title="The YUI Library can be downloaded from SourceForge" href="http://sourceforge.net/projects/yui/">YUI 3 on Sourceforge (external)</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/3/license.html">YUI License (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="item"><a title="YUI (Global Prerequisite) - Functional Examples" href="../../examples/yui/index.html">YUI (Global Prerequisite)</a></li><li class="item"><a title="Event - Functional Examples" href="../../examples/event/index.html">Event</a></li><li class="item"><a title="Node - Functional Examples" href="../../examples/node/index.html">Node</a></li><li class="sect">YUI 3 Component Infrastructure - Examples</li><li class="item"><a title="Attribute - Functional Examples" href="../../examples/attribute/index.html">Attribute</a></li><li class="item"><a title="Base - Functional Examples" href="../../examples/base/index.html">Base</a></li><li class="sect">YUI 3 Utilities - Examples</li><li class="item"><a title="Animation - Functional Examples" href="../../examples/anim/index.html">Animation</a></li><li class="item"><a title="Cookie - Functional Examples" href="../../examples/cookie/index.html">Cookie</a></li><li class="selected "><a title="Drag &amp; Drop - Functional Examples" href="../../examples/dd/index.html">Drag &amp; Drop</a></li><li class="item"><a title="Get - Functional Examples" href="../../examples/get/index.html">Get</a></li><li class="item"><a title="IO - Functional Examples" href="../../examples/io/index.html">IO</a></li><li class="item"><a title="JSON (JavaScript Object Notation) - Functional Examples" href="../../examples/json/index.html">JSON</a></li><li class="item"><a title="Queue - Functional Examples" href="../../examples/queue/index.html">Queue</a></li><li class="sect">YUI 3 CSS - Examples</li><li class="item"><a title="YUI CSS Reset - Functional Examples" href="../../examples/cssreset/index.html">CSS Reset</a></li><li class="item"><a title="YUI Fonts - Functional Examples" href="../../examples/cssfonts/index.html">CSS Fonts</a></li><li class="item"><a title="YUI Grids - Functional Examples" href="../../examples/cssgrids/index.html">CSS Grids</a></li><li class="item"><a title="YUI Base - Functional Examples" href="../../examples/cssbase/index.html">CSS Base</a></li><li class="sect">The YUI Community</li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="item"><a title="The Yahoo! Group YDN-JavaScript hosts the YUI community forum" href="http://tech.groups.yahoo.com/group/ydn-javascript/">YUI Forum (external)</a></li><li class="item"><a title="The Yahoo! Group yui3 is dedicated to the 3.x branch of the Yahoo! User Interface (YUI) Library." href="http://tech.groups.yahoo.com/group/yui3/">YUI 3 Forum (external)</a></li><li class="item"><a title="YUI is used by Yahoo! and by hundreds of other sites, including many you know and love." href="/yui/poweredby/">YUI Sightings (external)</a></li><li class="item"><a title="Videos and podcasts from the YUI Team and from the Yahoo! frontend engineering community." href="http://developer.yahoo.com/yui/theater/">YUI Theater (external)</a></li><li class="sect">YUI Articles on the YUI Website</li><li class="item"><a title="Answers to Frequently Asked Questions about the YUI Library" href="http://developer.yahoo.com/yui/articles/faq/">YUI FAQ (external)</a></li><li class="item"><a title="Yahoo!'s philosophy of Graded Browser Support" href="http://developer.yahoo.com/yui/articles/gbs/">Graded Browser Support (external)</a></li><li class="item"><a title="Reporting Bugs and Making Feature Requests for YUI Components" href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests (external)</a></li><li class="item"><a title="Serve YUI source files from Yahoo! -- free, fast, and simple" href="http://developer.yahoo.com/yui/3/articles/hosting/">Serving YUI Files from Yahoo! (external)</a></li></ul>
315</div>
316</div>
317        </div><!--closes bd-->
318
319        <div id="ft">
320        <p class="first">Copyright &copy; 2008 Yahoo! Inc. All rights reserved.</p>
321        <p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> -
322            <a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> -
323            <a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> -
324            <a href="http://careers.yahoo.com/">Job Openings</a></p>
325        </div>
326</div>
327<script src="../../assets/dpSyntaxHighlighter.js"></script>
328<script language="javascript"> 
329dp.SyntaxHighlighter.HighlightAll('code'); 
330</script>
331</body>
332</html>
333<!-- delightfuture.corp.yahoo.com uncompressed/chunked Wed Aug 13 16:45:30 PDT 2008 -->
Note: See TracBrowser for help on using the repository browser.