|
0
|
1 |
|
|
|
2 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
|
3 |
<html> |
|
|
4 |
<head> |
|
|
5 |
<title>YUI Library Examples: Drag & Drop: Simple Drag</title> |
|
|
6 |
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
7 |
<link rel="stylesheet" type="text/css" href="../../assets/yui.css" > |
|
|
8 |
|
|
|
9 |
<style> |
|
|
10 |
/*Supplemental CSS for the YUI distribution*/ |
|
|
11 |
#custom-doc { width: 95%; min-width: 950px; } |
|
|
12 |
#pagetitle {background-image: url(../../assets/bg_hd.gif);} |
|
|
13 |
/* #pagetitle h1 {background-image: url(../../assets/title_h_bg.gif);}*/ |
|
|
14 |
</style> |
|
|
15 |
|
|
|
16 |
<link rel="stylesheet" type="text/css" href="../../assets/dpSyntaxHighlighter.css"> |
|
|
17 |
|
|
|
18 |
<!--there is no custom header content for this example--> |
|
|
19 |
|
|
|
20 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
21 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
22 |
|
|
|
23 |
</head> |
|
|
24 |
<body id="yahoo-com" class=" yui-skin-sam"> |
|
|
25 |
<div id="custom-doc" class="yui-t2"> |
|
|
26 |
<div id="hd"> |
|
|
27 |
<div id="ygunav"> |
|
|
28 |
<p> |
|
|
29 |
<em> |
|
|
30 |
<a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> |
|
|
31 |
</em> |
|
|
32 |
</p> |
|
|
33 |
<form action="http://search.yahoo.com/search" id="sitesearchform"> |
|
|
34 |
<input name="vs" type="hidden" value="developer.yahoo.com"> |
|
|
35 |
<input name="vs" type="hidden" value="yuiblog.com"> |
|
|
36 |
<div id="sitesearch"> |
|
|
37 |
<label for="searchinput">Site Search (YDN & YUIBlog): </label> |
|
|
38 |
<input type="text" id="searchinput" name="p"> |
|
|
39 |
<input type="submit" value="Search" id="searchsubmit" class="ygbt"> |
|
|
40 |
</div> |
|
|
41 |
</form> |
|
|
42 |
</div> |
|
|
43 |
<div id="ygma"><a href="../../"><img src="../../assets/logo.gif" border="0" width="200" height="93"></a></div> |
|
|
44 |
<div id="pagetitle"><h1>YUI Library Examples: Drag & Drop: Simple Drag</h1></div> |
|
|
45 |
</div> |
|
|
46 |
<div id="bd"> |
|
|
47 |
|
|
|
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 & Drop: Simple Drag</h2> |
|
|
55 |
|
|
|
56 |
<div id="example" class="promo"> |
|
|
57 |
<div class="example-intro"> |
|
|
58 |
<p>This example shows a simple drag interaction that doesn't require a drop interaction.</p> |
|
|
59 |
</div> |
|
|
60 |
|
|
|
61 |
<div class="module example-container "> |
|
|
62 |
<div class="hd exampleHd"> |
|
|
63 |
<p class="newWindowButton yui-skin-sam"> |
|
|
64 |
<a href="simple-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 |
#demo { |
|
|
73 |
height: 100px; |
|
|
74 |
width: 100px; |
|
|
75 |
border: 1px solid black; |
|
|
76 |
background-color: #8DD5E7; |
|
|
77 |
cursor: move; |
|
|
78 |
} |
|
|
79 |
</style> |
|
|
80 |
|
|
|
81 |
<div id="demo">Drag Me</div> |
|
|
82 |
|
|
|
83 |
<script> |
|
|
84 |
|
|
|
85 |
YUI({base:"../../build/", timeout: 10000}).use('dd-drag', function(Y) { |
|
|
86 |
var dd = new Y.DD.Drag({ |
|
|
87 |
//Selector of the node to make draggable |
|
|
88 |
node: '#demo' |
|
|
89 |
}); |
|
|
90 |
}); |
|
|
91 |
</script> |
|
|
92 |
|
|
|
93 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
94 |
|
|
|
95 |
|
|
|
96 |
</div> |
|
|
97 |
</div> |
|
|
98 |
</div> |
|
|
99 |
|
|
|
100 |
<h3>Setting up the Node</h3> |
|
|
101 |
<p>First we need to create an HTML Node to make draggable.</p> |
|
|
102 |
<div id="syntax1" class="yui-syntax-highlight"><div class="numbers"><pre class="html4strict" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="sc2"><<span class="kw2">div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">"demo"</span>></span>Drag Me<span class="sc2"><<span class="sy0">/</span><span class="kw2">div</span>></span></div></li></ol></pre></div><div class="nonumbers"><pre class="html4strict" style="font-family:monospace;"><span class="sc2"><<span class="kw2">div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">"demo"</span>></span>Drag Me<span class="sc2"><<span class="sy0">/</span><span class="kw2">div</span>></span></pre></div><textarea id="syntax1-plain"><div id="demo">Drag Me</div></textarea></div> |
|
|
103 |
<p>Now we give that Node some CSS to make it visible.</p> |
|
|
104 |
<div id="syntax2" class="yui-syntax-highlight"><div class="numbers"><pre class="css" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="re0">#demo</span> <span class="br0">{</span></div></li><li class="li1"><div class="de1"> <span class="kw1">height</span><span class="sy0">:</span> <span class="re3">100px</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> <span class="kw1">width</span><span class="sy0">:</span> <span class="re3">100px</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> <span class="kw1">border</span><span class="sy0">:</span> <span class="re3">1px</span> <span class="kw2">solid</span> <span class="kw1">black</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2"> <span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#8DD5E7</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> <span class="kw1">cursor</span><span class="sy0">:</span> move<span class="sy0">;</span></div></li><li class="li1"><div class="de1"><span class="br0">}</span></div></li></ol></pre></div><div class="nonumbers"><pre class="css" style="font-family:monospace;"><span class="re0">#demo</span> <span class="br0">{</span> |
|
|
105 |
<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">100px</span><span class="sy0">;</span> |
|
|
106 |
<span class="kw1">width</span><span class="sy0">:</span> <span class="re3">100px</span><span class="sy0">;</span> |
|
|
107 |
<span class="kw1">border</span><span class="sy0">:</span> <span class="re3">1px</span> <span class="kw2">solid</span> <span class="kw1">black</span><span class="sy0">;</span> |
|
|
108 |
<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#8DD5E7</span><span class="sy0">;</span> |
|
|
109 |
<span class="kw1">cursor</span><span class="sy0">:</span> move<span class="sy0">;</span> |
|
|
110 |
<span class="br0">}</span></pre></div><textarea id="syntax2-plain">#demo { |
|
|
111 |
height: 100px; |
|
|
112 |
width: 100px; |
|
|
113 |
border: 1px solid black; |
|
|
114 |
background-color: #8DD5E7; |
|
|
115 |
cursor: move; |
|
|
116 |
}</textarea></div> |
|
|
117 |
<h3>Setting up the YUI Instance</h3> |
|
|
118 |
<p>Now we need to create our YUI instance and tell it to load the <code>dd-drag</code> module.</p> |
|
|
119 |
<div id="syntax3" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">YUI<span class="br0">(</span><span class="br0">)</span>.<span class="kw2">use</span><span class="br0">(</span><span class="st0">'dd-drag'</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">YUI<span class="br0">(</span><span class="br0">)</span>.<span class="kw2">use</span><span class="br0">(</span><span class="st0">'dd-drag'</span></pre></div><textarea id="syntax3-plain">YUI().use('dd-drag'</textarea></div> |
|
|
120 |
|
|
|
121 |
<h3>Making the Node draggable</h3> |
|
|
122 |
<p>Now that we have a YUI instance with the <code>dd-drag</code> module, we need to instantiate the <code>Drag</code> instance on this Node.</p> |
|
|
123 |
<div id="syntax4" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">YUI<span class="br0">(</span><span class="br0">)</span>.<span class="kw2">use</span><span class="br0">(</span><span class="st0">'dd-drag'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">(</span>Y<span class="br0">)</span> <span class="br0">{</span></div></li><li class="li1"><div class="de1"> <span class="co1">//Selector of the node to make draggable</span></div></li><li class="li1"><div class="de1"> <span class="kw2">var</span> dd <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">DD</span>.<span class="me1">Drag</span><span class="br0">(</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> node<span class="sy0">:</span> <span class="st0">'#demo'</span></div></li><li class="li2"><div class="de2"> <span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span> </div></li><li class="li1"><div class="de1"><span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">YUI<span class="br0">(</span><span class="br0">)</span>.<span class="kw2">use</span><span class="br0">(</span><span class="st0">'dd-drag'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">(</span>Y<span class="br0">)</span> <span class="br0">{</span> |
|
|
124 |
<span class="co1">//Selector of the node to make draggable</span> |
|
|
125 |
<span class="kw2">var</span> dd <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">DD</span>.<span class="me1">Drag</span><span class="br0">(</span><span class="br0">{</span> |
|
|
126 |
node<span class="sy0">:</span> <span class="st0">'#demo'</span> |
|
|
127 |
<span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span> |
|
|
128 |
<span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax4-plain">YUI().use('dd-drag', function(Y) { |
|
|
129 |
//Selector of the node to make draggable |
|
|
130 |
var dd = new Y.DD.Drag({ |
|
|
131 |
node: '#demo' |
|
|
132 |
}); |
|
|
133 |
});</textarea></div> </div> |
|
|
134 |
<div class="yui-u sidebar"> |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
<div id="examples" class="mod box4"> |
|
|
138 |
<div class="hd"> |
|
|
139 |
<h4> |
|
|
140 |
Drag & Drop Examples:</h4> |
|
|
141 |
</div> |
|
|
142 |
<div class="bd"> |
|
|
143 |
<ul> |
|
|
144 |
<li class='selected'><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><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/anim-drop.html'>Animated Drop Targets</a></li><li><a href='../dd/drop-code.html'>Drop Based Coding</a></li><li><a href='../dd/winscroll.html'>Window Scrolling</a></li><li><a href='../dd/list-drag.html'>List reorder w/Bubbling</a></li><li><a href='../dd/scroll-list.html'>List reorder w/Scrolling</a></li><li><a href='../dd/portal-drag.html'>Portal Style Example</a></li><li><a href='../dd/photo-browser.html'>Photo Browser</a></li><li><a href='../stylesheet/stylesheet_theme.html'>Adjusting a page theme on the fly (included with examples for StyleSheet)</a></li> </ul> |
|
|
145 |
</div> |
|
|
146 |
</div> |
|
|
147 |
|
|
|
148 |
<div class="mod box4"> |
|
|
149 |
<div class="hd"> |
|
|
150 |
<h4>More Drag & Drop Resources:</h4> |
|
|
151 |
</div> |
|
|
152 |
<div class="bd"> |
|
|
153 |
<ul> |
|
|
154 |
<!-- <li><a href="http://developer.yahoo.com/yui/dd/">User's Guide</a> (external)</li> --> |
|
|
155 |
<li><a href="../../api/module_dd.html">API Documentation</a></li></ul> |
|
|
156 |
</div> |
|
|
157 |
</div> |
|
|
158 |
</div> |
|
|
159 |
</div> |
|
|
160 |
|
|
|
161 |
</div> |
|
|
162 |
</div> |
|
|
163 |
|
|
|
164 |
|
|
|
165 |
<div class="yui-b toc3" id="tocWrapper"> |
|
|
166 |
<!-- TABLE OF CONTENTS --> |
|
|
167 |
<div id="toc"> |
|
|
168 |
|
|
|
169 |
<ul> |
|
|
170 |
<li class="sect first">YUI 3 Resources</li><li class="item"><a title="YUI 3 -- Yahoo! User Interface (YUI) Library" href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site</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="YUI 3 Dependency Configurator -- configure your custom YUI implementation" href="http://developer.yahoo.com/yui/3/configurator">YUI 3 Dependency Configurator</a></li><li class="item"><a title="The YUI 3 Forum on YUILibrary.com" href="http://yuilibrary.com/forum/viewforum.php?f=15">YUI 3 Forums (external)</a></li><li class="item"><a title="Found a bug or a missing feature? Let us know on YUILibrary.com." href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/license.html">YUI License</a></li><li class="item"><a title="Download and fork the YUI project on GitHub" href="http://github.com/yui">YUI on Github</a></li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="item"><a title="YUI Global Object - Functional Examples" href="../../examples/yui/index.html">YUI Global Object</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="Plugin - Functional Examples" href="../../examples/plugin/index.html">Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Widget - Functional Examples" href="../../examples/widget/index.html">Widget <img src='http://l.yimg.com/a/i/not/beta_1.gif'></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="AsyncQueue - Functional Examples" href="../../examples/async-queue/index.html">AsyncQueue</a></li><li class="item"><a title="Browser History - Functional Examples" href="../../examples/history/index.html">Browser History</a></li><li class="item"><a title="Cache - Functional Examples" href="../../examples/cache/index.html">Cache</a></li><li class="item"><a title="Cookie - Functional Examples" href="../../examples/cookie/index.html">Cookie</a></li><li class="item"><a title="DataSchema - Functional Examples" href="../../examples/dataschema/index.html">DataSchema <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataSource - Functional Examples" href="../../examples/datasource/index.html">DataSource <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataType - Functional Examples" href="../../examples/datatype/index.html">DataType <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="selected "><a title="Drag & Drop - Functional Examples" href="../../examples/dd/index.html">Drag & Drop</a></li><li class="item"><a title="Get - Functional Examples" href="../../examples/get/index.html">Get</a></li><li class="item"><a title="ImageLoader - Functional Examples" href="../../examples/imageloader/index.html">ImageLoader</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="Stylesheet - Functional Examples" href="../../examples/stylesheet/index.html">Stylesheet</a></li><li class="sect">YUI 3 Widgets - Examples</li><li class="item"><a title="Overlay - Functional Examples" href="../../examples/overlay/index.html">Overlay <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Slider - Functional Examples" href="../../examples/slider/index.html">Slider <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Node Plugins - Examples</li><li class="item"><a title="FocusManager Node Plugin - Functional Examples" href="../../examples/node-focusmanager/index.html">FocusManager Node Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="MenuNav Node Plugin - Functional Examples" href="../../examples/node-menunav/index.html">MenuNav Node Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></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 Base - Functional Examples" href="../../examples/cssbase/index.html">CSS Base</a></li><li class="sect">YUI 3 Developer Tools - Examples</li><li class="item"><a title="Console - Functional Examples" href="../../examples/console/index.html">Console <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Console Filters Plugin- Functional Examples" href="../../examples/console-filters/index.html">Plugin.ConsoleFilters <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Profiler - Functional Examples" href="../../examples/profiler/index.html">Profiler</a></li><li class="item"><a title="Test - Functional Examples" href="../../examples/test/index.html">Test</a></li><li class="sect">Other Useful YUI 3 Resources</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="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></ul> |
|
|
171 |
</div> |
|
|
172 |
</div> |
|
|
173 |
</div><!--closes bd--> |
|
|
174 |
|
|
|
175 |
<div id="ft"> |
|
|
176 |
<p class="first">Copyright © 2009 Yahoo! Inc. All rights reserved.</p> |
|
|
177 |
<p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> - |
|
|
178 |
<a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> - |
|
|
179 |
<a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> - |
|
|
180 |
<a href="http://careers.yahoo.com/">Job Openings</a></p> |
|
|
181 |
</div> |
|
|
182 |
</div> |
|
|
183 |
<script language="javascript"> |
|
|
184 |
var yuiConfig = {base:"../../build/", timeout: 10000}; |
|
|
185 |
</script> |
|
|
186 |
<script src="../../assets/syntax.js"></script> |
|
|
187 |
<script src="../../assets/dpSyntaxHighlighter.js"></script> |
|
|
188 |
<script language="javascript"> |
|
|
189 |
dp.SyntaxHighlighter.HighlightAll('code'); |
|
|
190 |
</script> |
|
|
191 |
</body> |
|
|
192 |
</html> |