|
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: The YUI Global Object: YUI 2.x and 3.x</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 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
18 |
<script type="text/javascript" src="../../build/yui/yui-debug.js"></script> |
|
|
19 |
<style type="text/css" id="styleoverrides"> |
|
|
20 |
#cal1Cont { |
|
|
21 |
background-color:#004C6D; |
|
|
22 |
} |
|
|
23 |
|
|
|
24 |
#cal1Cont div.calheader { |
|
|
25 |
cursor: move; |
|
|
26 |
} |
|
|
27 |
|
|
|
28 |
#cal1Cont .yui-calendar { |
|
|
29 |
width:auto; |
|
|
30 |
background-color:transparent; |
|
|
31 |
} |
|
|
32 |
|
|
|
33 |
#cal1Cont .yui-calendar tr, #cal1Cont .yui-calendar th { |
|
|
34 |
background-color:transparent; |
|
|
35 |
vertical-align:middle; |
|
|
36 |
text-transform:none; |
|
|
37 |
color:#fff; |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
#cal1Cont .yui-calendar a:hover { |
|
|
41 |
text-decoration:none; |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
#results { |
|
|
45 |
background-color:#8DD5E7; |
|
|
46 |
border:1px solid black; |
|
|
47 |
position: absolute; |
|
|
48 |
top: 15px; |
|
|
49 |
right: 5px; |
|
|
50 |
width: 300px; |
|
|
51 |
} |
|
|
52 |
</style> |
|
|
53 |
|
|
|
54 |
</head> |
|
|
55 |
<body id="yahoo-com" class=" yui-skin-sam"> |
|
|
56 |
<div id="custom-doc" class="yui-t2"> |
|
|
57 |
<div id="hd"> |
|
|
58 |
<div id="ygunav"> |
|
|
59 |
<p> |
|
|
60 |
<em> |
|
|
61 |
<a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> |
|
|
62 |
</em> |
|
|
63 |
</p> |
|
|
64 |
<form action="http://search.yahoo.com/search" id="sitesearchform"> |
|
|
65 |
<input name="vs" type="hidden" value="developer.yahoo.com"> |
|
|
66 |
<input name="vs" type="hidden" value="yuiblog.com"> |
|
|
67 |
<div id="sitesearch"> |
|
|
68 |
<label for="searchinput">Site Search (YDN & YUIBlog): </label> |
|
|
69 |
<input type="text" id="searchinput" name="p"> |
|
|
70 |
<input type="submit" value="Search" id="searchsubmit" class="ygbt"> |
|
|
71 |
</div> |
|
|
72 |
</form> |
|
|
73 |
</div> |
|
|
74 |
<div id="ygma"><a href="../../"><img src="../../assets/logo.gif" border="0" width="200" height="93"></a></div> |
|
|
75 |
<div id="pagetitle"><h1>YUI Library Examples: The YUI Global Object: YUI 2.x and 3.x</h1></div> |
|
|
76 |
</div> |
|
|
77 |
<div id="bd"> |
|
|
78 |
|
|
|
79 |
<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> |
|
|
80 |
|
|
|
81 |
<div id="yui-main"> |
|
|
82 |
<div class="yui-b"> |
|
|
83 |
<div class="yui-ge"> |
|
|
84 |
<div class="yui-u first example" id="main"> |
|
|
85 |
|
|
|
86 |
<h2>The YUI Global Object: YUI 2.x and 3.x</h2> |
|
|
87 |
|
|
|
88 |
<div id="example" class="promo"> |
|
|
89 |
<p> |
|
|
90 |
<p>This example shows how to use YUI 2.x and 3.x at the same time as well as interacting with each other. We will make a 2.x Calendar Control draggable with 3.x Drag & Drop and use 3.x's Node to handle the Calendar's Select Event.</p> |
|
|
91 |
</p> |
|
|
92 |
|
|
|
93 |
<div class="module example-container "> |
|
|
94 |
<div class="hd exampleHd"> |
|
|
95 |
<p class="newWindowButton yui-skin-sam"> |
|
|
96 |
<a href="yui-compat_clean.html" target="_blank">View example in new window.</a> |
|
|
97 |
</p> |
|
|
98 |
</div> <div id="example-canvas" class="bd"> |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
102 |
|
|
|
103 |
<!-- css --> |
|
|
104 |
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/calendar/assets/skins/sam/calendar.css"> |
|
|
105 |
<!-- js --> |
|
|
106 |
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script> |
|
|
107 |
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/calendar/calendar-min.js"></script> |
|
|
108 |
|
|
|
109 |
<div id="cal1Cont"></div> |
|
|
110 |
|
|
|
111 |
<div id="results">Click a date..</div> |
|
|
112 |
|
|
|
113 |
<script> |
|
|
114 |
|
|
|
115 |
YUI({base:"../../build/", timeout: 10000, filter:"debug", logInclude: {example:true}}).use("dd", |
|
|
116 |
|
|
|
117 |
function(Y) { |
|
|
118 |
var cal1 = new YAHOO.widget.Calendar('cal1', 'cal1Cont'); |
|
|
119 |
cal1.renderEvent.subscribe(function() { |
|
|
120 |
var dd = new Y.DD.Drag({ |
|
|
121 |
node: '#cal1Cont' |
|
|
122 |
}).addHandle('div.calheader'); |
|
|
123 |
}); |
|
|
124 |
cal1.selectEvent.subscribe(function(e, dates) { |
|
|
125 |
var d = dates[0][0]; |
|
|
126 |
var dateStr = d[1] + '/' + d[2] + '/' + d[0]; |
|
|
127 |
Y.Node.get('#results').set('innerHTML', 'You clicked on: ' + dateStr); |
|
|
128 |
}); |
|
|
129 |
cal1.render(); |
|
|
130 |
}); |
|
|
131 |
</script> |
|
|
132 |
|
|
|
133 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
134 |
|
|
|
135 |
|
|
|
136 |
</div> |
|
|
137 |
</div> |
|
|
138 |
</div> |
|
|
139 |
|
|
|
140 |
<h3>Including YUI 2.x</h3> |
|
|
141 |
<p>First we will include the code for the 2.x Calendar Control and its dependencies.</p> |
|
|
142 |
<textarea name="code" class="HTML"> |
|
|
143 |
<!-- css --> |
|
|
144 |
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/calendar/assets/skins/sam/calendar.css"> |
|
|
145 |
<!-- js --> |
|
|
146 |
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js"></script> |
|
|
147 |
<script type="text/javascript" src="http://yui.yahooapis.com/2.5.2/build/calendar/calendar-min.js"></script> |
|
|
148 |
</textarea> |
|
|
149 |
|
|
|
150 |
<h3>Creating your YUI instance</h3> |
|
|
151 |
<p>Now we need to create our YUI instance with the <code>dd-drag</code> module, so we can make the calendar draggable.</p> |
|
|
152 |
<textarea name="code" class="JScript"> |
|
|
153 |
YUI().use('dd-drag', function(Y) { |
|
|
154 |
}); |
|
|
155 |
</textarea> |
|
|
156 |
|
|
|
157 |
<h3>Creating the Calendar</h3> |
|
|
158 |
<p>Now that we have our tools in place, let's create the calendar.</p> |
|
|
159 |
<textarea name="code" class="JScript"> |
|
|
160 |
YUI().use('dd-drag', function(Y) { |
|
|
161 |
var cal1 = new YAHOO.widget.Calendar('cal1', 'cal1Cont'); |
|
|
162 |
cal1.render(); |
|
|
163 |
}); |
|
|
164 |
</textarea> |
|
|
165 |
|
|
|
166 |
<h3>Making it draggable</h3> |
|
|
167 |
<p>Now we make the calendar draggable with the 3.x <code>dd-drag</code> module.</p> |
|
|
168 |
<textarea name="code" class="JScript"> |
|
|
169 |
YUI().use('dd-drag', function(Y) { |
|
|
170 |
var cal1 = new YAHOO.widget.Calendar('cal1', 'cal1Cont'); |
|
|
171 |
cal1.renderEvent.subscribe(function() { |
|
|
172 |
var dd = new Y.DD.Drag({ |
|
|
173 |
node: '#cal1Cont' |
|
|
174 |
}).addHandle('div.calheader'); |
|
|
175 |
}); |
|
|
176 |
cal1.render(); |
|
|
177 |
}); |
|
|
178 |
</textarea> |
|
|
179 |
|
|
|
180 |
<h3>Handling the Calendars Select Event with Node</h3> |
|
|
181 |
<p>Now we need to hook up the <code>selectEvent</code> and handle that with 3.x's <code>Node</code>.</p> |
|
|
182 |
<textarea name="code" class="JScript"> |
|
|
183 |
YUI().use('dd-drag', function(Y) { |
|
|
184 |
var cal1 = new YAHOO.widget.Calendar('cal1', 'cal1Cont'); |
|
|
185 |
cal1.renderEvent.subscribe(function() { |
|
|
186 |
var dd = new Y.DD.Drag({ |
|
|
187 |
node: '#cal1Cont' |
|
|
188 |
}).addHandle('div.calheader'); |
|
|
189 |
}); |
|
|
190 |
cal1.selectEvent.subscribe(function(e, dates) { |
|
|
191 |
var d = dates[0][0]; |
|
|
192 |
var dateStr = d[1] + '/' + d[2] + '/' + d[0]; |
|
|
193 |
Y.Node.get('#results').set('innerHTML', 'You clicked on: ' + dateStr); |
|
|
194 |
}); |
|
|
195 |
cal1.render(); |
|
|
196 |
}); |
|
|
197 |
</textarea> |
|
|
198 |
|
|
|
199 |
</div> |
|
|
200 |
<div class="yui-u sidebar"> |
|
|
201 |
|
|
|
202 |
|
|
|
203 |
<div id="examples" class="mod box4"> |
|
|
204 |
<div class="hd"> |
|
|
205 |
<h4> |
|
|
206 |
The YUI Global Object Examples:</h4> |
|
|
207 |
</div> |
|
|
208 |
<div class="bd"> |
|
|
209 |
<ul> |
|
|
210 |
<li><a href='../yui/yui-core.html'>YUI Core</a></li><li><a href='../yui/yui-more.html'>Load All Modules</a></li><li><a href='../yui/yui-multi.html'>Multiple Instances</a></li><li class='selected'><a href='../yui/yui-compat.html'>YUI 2.x and 3.x</a></li><li><a href='../yui/yui-loader-ext.html'>YUI Loader - Dynamically Adding YUI and External Modules</a></li><li><a href='../yui/yui-extend.html'>Create Class Hierarchies with <code>extend</code></a></li><li><a href='../yui/yui-augment.html'>Compose Classes of Objects with <code>augment</code></a></li><li><a href='../yui/yui-mix.html'>Add Behaviors to Objects with <code>mix</code></a></li><li><a href='../yui/yui-merge.html'>Combine Data Sets with <code>merge</code></a></li><li><a href='../yui/yui-isa.html'>Check Data Types with <code>Lang</code></a></li><li><a href='../yui/yui-ua.html'>Browser Detection with <code>UA</code></a></li> </ul> |
|
|
211 |
</div> |
|
|
212 |
</div> |
|
|
213 |
|
|
|
214 |
<div class="mod box4"> |
|
|
215 |
<div class="hd"> |
|
|
216 |
<h4>More The YUI Global Object Resources:</h4> |
|
|
217 |
</div> |
|
|
218 |
<div class="bd"> |
|
|
219 |
<ul> |
|
|
220 |
<!-- <li><a href="http://developer.yahoo.com/yui/yui/">User's Guide</a> (external)</li> --> |
|
|
221 |
<li><a href="../../api/module_yui.html">API Documentation</a></li> |
|
|
222 |
</ul> |
|
|
223 |
</div> |
|
|
224 |
</div> |
|
|
225 |
</div> |
|
|
226 |
</div> |
|
|
227 |
|
|
|
228 |
</div> |
|
|
229 |
</div> |
|
|
230 |
|
|
|
231 |
|
|
|
232 |
<div class="yui-b toc3" id="tocWrapper"> |
|
|
233 |
<!-- TABLE OF CONTENTS --> |
|
|
234 |
<div id="toc"> |
|
|
235 |
|
|
|
236 |
<ul> |
|
|
237 |
<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="selected "><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="Plugin - Functional Examples" href="../../examples/plugin/index.html">Plugin</a></li><li class="item"><a title="Widget - Functional Examples" href="../../examples/widget/index.html">Widget</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="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</a></li><li class="item"><a title="DataSource - Functional Examples" href="../../examples/datasource/index.html">DataSource</a></li><li class="item"><a title="DataType - Functional Examples" href="../../examples/datatype/index.html">DataType</a></li><li class="item"><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="History - Functional Examples" href="../../examples/history/index.html">History</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="Queue - Functional Examples" href="../../examples/queue/index.html">Queue</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</a></li><li class="item"><a title="Slider - Functional Examples" href="../../examples/slider/index.html">Slider</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</a></li><li class="item"><a title="MenuNav Node Plugin - Functional Examples" href="../../examples/node-menunav/index.html">MenuNav Node Plugin</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</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">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> |
|
|
238 |
</div> |
|
|
239 |
</div> |
|
|
240 |
</div><!--closes bd--> |
|
|
241 |
|
|
|
242 |
<div id="ft"> |
|
|
243 |
<p class="first">Copyright © 2009 Yahoo! Inc. All rights reserved.</p> |
|
|
244 |
<p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> - |
|
|
245 |
<a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> - |
|
|
246 |
<a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> - |
|
|
247 |
<a href="http://careers.yahoo.com/">Job Openings</a></p> |
|
|
248 |
</div> |
|
|
249 |
</div> |
|
|
250 |
<script src="../../assets/dpSyntaxHighlighter.js"></script> |
|
|
251 |
<script language="javascript"> |
|
|
252 |
dp.SyntaxHighlighter.HighlightAll('code'); |
|
|
253 |
</script> |
|
|
254 |
</body> |
|
|
255 |
</html> |