|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Dial With Interactive UI</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
<a href="#toc" class="jump">Jump to Table of Contents</a> |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
<h1>Example: Dial With Interactive UI</h1> |
|
|
27 |
<div class="yui3-g"> |
|
|
28 |
<div class="yui3-u-3-4"> |
|
|
29 |
<div id="main"> |
|
|
30 |
<div class="content"><div class="intro"> |
|
|
31 |
<p>This <code>Dial</code> widget example shows the following:</p> |
|
|
32 |
|
|
|
33 |
<ol> |
|
|
34 |
<li>A demonstration of a large value range combined with fine increment control.</li> |
|
|
35 |
<li>Setting UI strings before rendering</li> |
|
|
36 |
<li>Setting configuration attributes</li> |
|
|
37 |
<li>Construction-time event subscription allowing Dial to control an interactive UI</li> |
|
|
38 |
<li>Calling one of Dial's value change methods from the click of a link. <code><a>Hubble</a></code></li> |
|
|
39 |
</ol> |
|
|
40 |
<p>Notice the Dial can traverse the entire 6,000+ pixels of the scene height, but by pulling the handle |
|
|
41 |
farther away from the Dial's center while rotating, the user can get 1 pixel movements, without strain. |
|
|
42 |
After the dial has focus, the following keys also opperate the Dial, arrow up/down/left/right, page up/down, home, end. The action of these keys can be controlled via <a href="index.html#attributes" title="YUI 3: Dial">Dial's configuration attributes</a>.</p> |
|
|
43 |
</div> |
|
|
44 |
|
|
|
45 |
<div class="example yui3-skin-sam"> |
|
|
46 |
<style> |
|
|
47 |
#example_container { |
|
|
48 |
position:relative; |
|
|
49 |
} |
|
|
50 |
#demo{ |
|
|
51 |
margin:0; |
|
|
52 |
position:absolute; |
|
|
53 |
top:321px; |
|
|
54 |
left:0; |
|
|
55 |
} |
|
|
56 |
.controls { |
|
|
57 |
position:absolute; |
|
|
58 |
top:0; |
|
|
59 |
left:328px; |
|
|
60 |
margin:0 0 0 0; |
|
|
61 |
color:#808080; |
|
|
62 |
width:300px; |
|
|
63 |
} |
|
|
64 |
.controls a { |
|
|
65 |
color:#4B78D9 !important; |
|
|
66 |
cursor:pointer; |
|
|
67 |
} |
|
|
68 |
.intro-sentence{ |
|
|
69 |
font-size: 183%; |
|
|
70 |
left: 0; |
|
|
71 |
line-height: 0.9em; |
|
|
72 |
position: absolute; |
|
|
73 |
top: 273px; |
|
|
74 |
width: 6em; |
|
|
75 |
} |
|
|
76 |
#view_frame{ |
|
|
77 |
position:relative; |
|
|
78 |
height:500px; |
|
|
79 |
width:300px; |
|
|
80 |
border:solid 1px #cccccc; |
|
|
81 |
overflow:hidden; |
|
|
82 |
} |
|
|
83 |
#scene{position:absolute; |
|
|
84 |
left:0; |
|
|
85 |
top:-6440px; |
|
|
86 |
height:6440px; |
|
|
87 |
width:100%; |
|
|
88 |
background:url(../assets/dial/images/earth_to_hubble_bkg.png) repeat; |
|
|
89 |
} |
|
|
90 |
#altitude_mark { |
|
|
91 |
border-top:solid 1px #CCCCCC; |
|
|
92 |
left:-33px; |
|
|
93 |
position:absolute; |
|
|
94 |
top:403px; |
|
|
95 |
width:30px; |
|
|
96 |
} |
|
|
97 |
#earth{ |
|
|
98 |
position:absolute; |
|
|
99 |
left:0; |
|
|
100 |
top:5834px; |
|
|
101 |
height:214px; |
|
|
102 |
width:300px; |
|
|
103 |
} |
|
|
104 |
#hubble{ |
|
|
105 |
position:absolute; |
|
|
106 |
left:5px; |
|
|
107 |
top:7px; |
|
|
108 |
height:393px; |
|
|
109 |
width:300px; |
|
|
110 |
} |
|
|
111 |
#stars{ |
|
|
112 |
position:absolute; |
|
|
113 |
left:0; |
|
|
114 |
top:0; |
|
|
115 |
background:url(../assets/dial/images/stars.png) repeat; |
|
|
116 |
height:5000px; |
|
|
117 |
width:300px; |
|
|
118 |
} |
|
|
119 |
.label{ |
|
|
120 |
text-transform:uppercase; |
|
|
121 |
width:100%; |
|
|
122 |
letter-spacing:5px; |
|
|
123 |
font-family:Verdana; |
|
|
124 |
font-size:85%; |
|
|
125 |
position:absolute; |
|
|
126 |
left:0; |
|
|
127 |
text-align:center; |
|
|
128 |
} |
|
|
129 |
.hubble{ |
|
|
130 |
bottom:6023px; |
|
|
131 |
color:#612C88; |
|
|
132 |
} |
|
|
133 |
.thermosphere{ |
|
|
134 |
bottom:1290px; |
|
|
135 |
color:#5A009D; |
|
|
136 |
} |
|
|
137 |
.mesosphere{ |
|
|
138 |
bottom:840px; |
|
|
139 |
color:#570BFF; |
|
|
140 |
} |
|
|
141 |
.stratosphere{ |
|
|
142 |
bottom:540px; |
|
|
143 |
color:#006999; |
|
|
144 |
} |
|
|
145 |
.troposphere{ |
|
|
146 |
bottom:477px; |
|
|
147 |
color:#036585; |
|
|
148 |
} |
|
|
149 |
.ozone{ |
|
|
150 |
bottom:692px; |
|
|
151 |
color:#005AAE; |
|
|
152 |
} |
|
|
153 |
.crust{ |
|
|
154 |
bottom:270px; |
|
|
155 |
color:#4F2D00; |
|
|
156 |
} |
|
|
157 |
.mantle{ |
|
|
158 |
bottom:42px; |
|
|
159 |
color:#897701; |
|
|
160 |
} |
|
|
161 |
</style> |
|
|
162 |
|
|
|
163 |
<div id="example_container"> |
|
|
164 |
<div id="view_frame"> |
|
|
165 |
<div id="scene"> |
|
|
166 |
<div id="stars"></div> |
|
|
167 |
<img id="hubble" src="http://yuilibrary.com/yui/docs/assets/dial/images/hubble.png"/> |
|
|
168 |
<img id="earth" src="http://yuilibrary.com/yui/docs/assets/dial/images/mountain_earth.png"/> |
|
|
169 |
<div class="label hubble">hubble</div> |
|
|
170 |
<div class="label thermosphere">thermosphere</div> |
|
|
171 |
<div class="label mesosphere">mesosphere</div> |
|
|
172 |
<div class="label stratosphere">stratosphere</div> |
|
|
173 |
<div class="label troposphere">troposphere</div> |
|
|
174 |
<div class="label ozone">ozone</div> |
|
|
175 |
<div class="label crust">crust</div> |
|
|
176 |
<div class="label mantle">mantle</div> |
|
|
177 |
</div> |
|
|
178 |
</div> |
|
|
179 |
<div class="controls"> |
|
|
180 |
<div class="intro-sentence">From Earth to <a id="a-hubble">Hubble</a></div> |
|
|
181 |
<div id="altitude_mark"></div> |
|
|
182 |
<div id="demo"></div> |
|
|
183 |
</div> |
|
|
184 |
</div> |
|
|
185 |
|
|
|
186 |
<script> |
|
|
187 |
YUI().use('dial', function(Y) { |
|
|
188 |
|
|
|
189 |
var sceneH = Y.one('#scene').get('region').height, |
|
|
190 |
subSea = 450, |
|
|
191 |
viewFrameH = Y.one('#view_frame').get('region').height -2, |
|
|
192 |
zeroPt = 100, |
|
|
193 |
originY = -sceneH + subSea + viewFrameH - zeroPt; |
|
|
194 |
|
|
|
195 |
Y.one('#scene').setStyle('top', originY + 'px'); |
|
|
196 |
|
|
|
197 |
/** |
|
|
198 |
* The Dial's valueChange event is passed to this. |
|
|
199 |
* sets the CSS top value of the pictoral scene of the earth to the hubble. |
|
|
200 |
* This scene is an absolute positioned div inside another div with |
|
|
201 |
* overflow set to hidden. |
|
|
202 |
*/ |
|
|
203 |
setSceneY = function(e) { |
|
|
204 |
Y.one('#scene').setStyle('top', (originY + (e.newVal * 10)) + 'px'); |
|
|
205 |
} |
|
|
206 |
|
|
|
207 |
var dial = new Y.Dial({ |
|
|
208 |
min:-35, |
|
|
209 |
max:559, |
|
|
210 |
stepsPerRevolution:30, |
|
|
211 |
value: 0, |
|
|
212 |
diameter: 100, |
|
|
213 |
minorStep: 1, |
|
|
214 |
majorStep: 10, |
|
|
215 |
decimalPlaces: 2, |
|
|
216 |
strings:{label:'Altitude in Kilometers:', resetStr: 'Reset', tooltipHandle: 'Drag to set'}, |
|
|
217 |
// construction-time event subscription |
|
|
218 |
after : { |
|
|
219 |
valueChange: Y.bind( setSceneY, dial ) |
|
|
220 |
} |
|
|
221 |
}); |
|
|
222 |
dial.render('#demo'); |
|
|
223 |
|
|
|
224 |
// Function that calls a method in Dial that sets its value to the value of the max config attribute |
|
|
225 |
// Other methods available include, |
|
|
226 |
// _setToMin(), _resetDial(), _incrMinor(), _decrMinor(), _incrMajor(), _decrMajor(), |
|
|
227 |
var setDialToMax = function(e){ |
|
|
228 |
e.preventDefault(); |
|
|
229 |
this._setToMax(); |
|
|
230 |
} |
|
|
231 |
|
|
|
232 |
// Subscribe to the click of the "Hubble" anchor, passing the dial as the 'this' |
|
|
233 |
Y.on('click', setDialToMax, '#a-hubble', dial); |
|
|
234 |
|
|
|
235 |
}); |
|
|
236 |
</script> |
|
|
237 |
</div> |
|
|
238 |
|
|
|
239 |
<h3 id="making-a-dial-drive-an-interactive-ui">Making a Dial Drive an Interactive UI</h3> |
|
|
240 |
|
|
|
241 |
<p>The <code>valueChange</code> event of a <code>Dial</code> can be the means of controlling other UI displayed on a page.</p> |
|
|
242 |
|
|
|
243 |
<h4 id="the-markup">The Markup</h4> |
|
|
244 |
<p> |
|
|
245 |
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the |
|
|
246 |
page's <code><body></code> element or to a parent element of the widget in order to apply |
|
|
247 |
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>. |
|
|
248 |
</p> |
|
|
249 |
<pre class="code prettyprint"><body class="yui3-skin-sam"> <!-- You need this skin class --></pre> |
|
|
250 |
|
|
|
251 |
<p>The only markup requirement for the <code>Dial</code> itself is an element to contain the Dial. |
|
|
252 |
The rest of the markup and CSS in this example is just for the Hubble telescope visualization. |
|
|
253 |
</p> |
|
|
254 |
|
|
|
255 |
<pre class="code prettyprint"><div id="demo"></div></pre> |
|
|
256 |
|
|
|
257 |
|
|
|
258 |
<h4 id="the-javascript">The JavaScript</h4> |
|
|
259 |
|
|
|
260 |
<p>This example builds on previous examples by showing how to modify the visible UI strings before the dial renders.</p> |
|
|
261 |
|
|
|
262 |
<p>During instatiation of a Dial, several configuration attributes can be set (see the code-block below); note the construction-time event subscription:</p> |
|
|
263 |
|
|
|
264 |
<pre class="code prettyprint">YUI().use('dial', function(Y) { |
|
|
265 |
|
|
|
266 |
var sceneH = Y.one('#scene').get('region').height, |
|
|
267 |
subSea = 450, |
|
|
268 |
viewFrameH = Y.one('#view_frame').get('region').height -2, |
|
|
269 |
zeroPt = 100, |
|
|
270 |
originY = -sceneH + subSea + viewFrameH - zeroPt; |
|
|
271 |
|
|
|
272 |
Y.one('#scene').setStyle('top', originY + 'px'); |
|
|
273 |
|
|
|
274 |
/** |
|
|
275 |
* The Dial's valueChange event is passed to this. |
|
|
276 |
* sets the CSS top value of the pictoral scene of the earth to the hubble. |
|
|
277 |
* This scene is an absolute positioned div inside another div with |
|
|
278 |
* overflow set to hidden. |
|
|
279 |
*/ |
|
|
280 |
setSceneY = function(e) { |
|
|
281 |
Y.one('#scene').setStyle('top', (originY + (e.newVal * 10)) + 'px'); |
|
|
282 |
} |
|
|
283 |
|
|
|
284 |
var dial = new Y.Dial({ |
|
|
285 |
min:-35, |
|
|
286 |
max:559, |
|
|
287 |
stepsPerRevolution:30, |
|
|
288 |
value: 0, |
|
|
289 |
diameter: 100, |
|
|
290 |
minorStep: 1, |
|
|
291 |
majorStep: 10, |
|
|
292 |
decimalPlaces: 2, |
|
|
293 |
strings:{label:'Altitude in Kilometers:', resetStr: 'Reset', tooltipHandle: 'Drag to set'}, |
|
|
294 |
// construction-time event subscription |
|
|
295 |
after : { |
|
|
296 |
valueChange: Y.bind( setSceneY, dial ) |
|
|
297 |
} |
|
|
298 |
}); |
|
|
299 |
dial.render('#demo'); |
|
|
300 |
|
|
|
301 |
// Function that calls a method in Dial that sets its value to the value of the max config attribute |
|
|
302 |
// Other methods available include, |
|
|
303 |
// _setToMin(), _resetDial(), _incrMinor(), _decrMinor(), _incrMajor(), _decrMajor(), |
|
|
304 |
var setDialToMax = function(e){ |
|
|
305 |
e.preventDefault(); |
|
|
306 |
this._setToMax(); |
|
|
307 |
} |
|
|
308 |
|
|
|
309 |
// Subscribe to the click of the "Hubble" anchor, passing the dial as the 'this' |
|
|
310 |
Y.on('click', setDialToMax, '#a-hubble', dial); |
|
|
311 |
|
|
|
312 |
});</pre> |
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
<h5 id="the-event-handler">The Event Handler</h5> |
|
|
317 |
|
|
|
318 |
<p> |
|
|
319 |
Preceding the code that instantiates the <code>Dial</code> widget, declare the event handler. |
|
|
320 |
We can use the value of the <code>Dial</code> to do whatever we want, but |
|
|
321 |
in this example the event handler updates the CSS <code>top</code> property of the pictorial scene <code><div id="scene"></code> of Hubble's relationship to Earth. |
|
|
322 |
This scene is moved up or down inside a framing element <code><div class="viewframe"></code> that has CSS <code>overflow:hidden;</code>. |
|
|
323 |
The reason <code>e.newVal</code> is multiplied by <code>10</code> is so that the scene moves 10px for every 1 kilometer of the <code>Dial</code>'s value. |
|
|
324 |
</p> |
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
<pre class="code prettyprint">/** |
|
|
329 |
* The Dial's valueChange event is passed to this. |
|
|
330 |
* sets the CSS top value of the pictoral scene of the earth to the hubble. |
|
|
331 |
* This scene is an absolute positioned div inside another div with |
|
|
332 |
* overflow set to hidden. |
|
|
333 |
*/ |
|
|
334 |
setSceneY = function(e) { |
|
|
335 |
Y.one('#scene').setStyle('top', (originY + (e.newVal * 10)) + 'px'); |
|
|
336 |
}</pre> |
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
<h3 id="complete-example-source">Complete Example Source</h3> |
|
|
341 |
<pre class="code prettyprint"><!DOCTYPE HTML> |
|
|
342 |
<html> |
|
|
343 |
<script src="http://yui.yahooapis.com/3.10.3/build/yui/yui-min.js"></script> |
|
|
344 |
|
|
|
345 |
<style> |
|
|
346 |
#example_container { |
|
|
347 |
position:relative; |
|
|
348 |
} |
|
|
349 |
#demo{ |
|
|
350 |
margin:0; |
|
|
351 |
position:absolute; |
|
|
352 |
top:321px; |
|
|
353 |
left:0; |
|
|
354 |
} |
|
|
355 |
.controls { |
|
|
356 |
position:absolute; |
|
|
357 |
top:0; |
|
|
358 |
left:328px; |
|
|
359 |
margin:0 0 0 0; |
|
|
360 |
color:#808080; |
|
|
361 |
width:300px; |
|
|
362 |
} |
|
|
363 |
.controls a { |
|
|
364 |
color:#4B78D9 !important; |
|
|
365 |
cursor:pointer; |
|
|
366 |
} |
|
|
367 |
.intro-sentence{ |
|
|
368 |
font-size: 183%; |
|
|
369 |
left: 0; |
|
|
370 |
line-height: 0.9em; |
|
|
371 |
position: absolute; |
|
|
372 |
top: 273px; |
|
|
373 |
width: 6em; |
|
|
374 |
} |
|
|
375 |
#view_frame{ |
|
|
376 |
position:relative; |
|
|
377 |
height:500px; |
|
|
378 |
width:300px; |
|
|
379 |
border:solid 1px #cccccc; |
|
|
380 |
overflow:hidden; |
|
|
381 |
} |
|
|
382 |
#scene{position:absolute; |
|
|
383 |
left:0; |
|
|
384 |
top:-6440px; |
|
|
385 |
height:6440px; |
|
|
386 |
width:100%; |
|
|
387 |
background:url(../assets/dial/images/earth_to_hubble_bkg.png) repeat; |
|
|
388 |
} |
|
|
389 |
#altitude_mark { |
|
|
390 |
border-top:solid 1px #CCCCCC; |
|
|
391 |
left:-33px; |
|
|
392 |
position:absolute; |
|
|
393 |
top:403px; |
|
|
394 |
width:30px; |
|
|
395 |
} |
|
|
396 |
#earth{ |
|
|
397 |
position:absolute; |
|
|
398 |
left:0; |
|
|
399 |
top:5834px; |
|
|
400 |
height:214px; |
|
|
401 |
width:300px; |
|
|
402 |
} |
|
|
403 |
#hubble{ |
|
|
404 |
position:absolute; |
|
|
405 |
left:5px; |
|
|
406 |
top:7px; |
|
|
407 |
height:393px; |
|
|
408 |
width:300px; |
|
|
409 |
} |
|
|
410 |
#stars{ |
|
|
411 |
position:absolute; |
|
|
412 |
left:0; |
|
|
413 |
top:0; |
|
|
414 |
background:url(../assets/dial/images/stars.png) repeat; |
|
|
415 |
height:5000px; |
|
|
416 |
width:300px; |
|
|
417 |
} |
|
|
418 |
.label{ |
|
|
419 |
text-transform:uppercase; |
|
|
420 |
width:100%; |
|
|
421 |
letter-spacing:5px; |
|
|
422 |
font-family:Verdana; |
|
|
423 |
font-size:85%; |
|
|
424 |
position:absolute; |
|
|
425 |
left:0; |
|
|
426 |
text-align:center; |
|
|
427 |
} |
|
|
428 |
.hubble{ |
|
|
429 |
bottom:6023px; |
|
|
430 |
color:#612C88; |
|
|
431 |
} |
|
|
432 |
.thermosphere{ |
|
|
433 |
bottom:1290px; |
|
|
434 |
color:#5A009D; |
|
|
435 |
} |
|
|
436 |
.mesosphere{ |
|
|
437 |
bottom:840px; |
|
|
438 |
color:#570BFF; |
|
|
439 |
} |
|
|
440 |
.stratosphere{ |
|
|
441 |
bottom:540px; |
|
|
442 |
color:#006999; |
|
|
443 |
} |
|
|
444 |
.troposphere{ |
|
|
445 |
bottom:477px; |
|
|
446 |
color:#036585; |
|
|
447 |
} |
|
|
448 |
.ozone{ |
|
|
449 |
bottom:692px; |
|
|
450 |
color:#005AAE; |
|
|
451 |
} |
|
|
452 |
.crust{ |
|
|
453 |
bottom:270px; |
|
|
454 |
color:#4F2D00; |
|
|
455 |
} |
|
|
456 |
.mantle{ |
|
|
457 |
bottom:42px; |
|
|
458 |
color:#897701; |
|
|
459 |
} |
|
|
460 |
</style> |
|
|
461 |
|
|
|
462 |
<body class="yui3-skin-sam"> <!-- You need this skin class --> |
|
|
463 |
<div id="example_container"> |
|
|
464 |
<div id="view_frame"> |
|
|
465 |
<div id="scene"> |
|
|
466 |
<div id="stars"></div> |
|
|
467 |
<img id="hubble" src="http://yuilibrary.com/yui/docs/assets/dial/images/hubble.png"/> |
|
|
468 |
<img id="earth" src="http://yuilibrary.com/yui/docs/assets/dial/images/mountain_earth.png"/> |
|
|
469 |
<div class="label hubble">hubble</div> |
|
|
470 |
<div class="label thermosphere">thermosphere</div> |
|
|
471 |
<div class="label mesosphere">mesosphere</div> |
|
|
472 |
<div class="label stratosphere">stratosphere</div> |
|
|
473 |
<div class="label troposphere">troposphere</div> |
|
|
474 |
<div class="label ozone">ozone</div> |
|
|
475 |
<div class="label crust">crust</div> |
|
|
476 |
<div class="label mantle">mantle</div> |
|
|
477 |
</div> |
|
|
478 |
</div> |
|
|
479 |
<div class="controls"> |
|
|
480 |
<div class="intro-sentence">From Earth to <a id="a-hubble">Hubble</a></div> |
|
|
481 |
<div id="altitude_mark"></div> |
|
|
482 |
<div id="demo"></div> |
|
|
483 |
</div> |
|
|
484 |
</div> |
|
|
485 |
</body> |
|
|
486 |
|
|
|
487 |
<script> |
|
|
488 |
YUI().use('dial', function(Y) { |
|
|
489 |
|
|
|
490 |
var sceneH = Y.one('#scene').get('region').height, |
|
|
491 |
subSea = 450, |
|
|
492 |
viewFrameH = Y.one('#view_frame').get('region').height -2, |
|
|
493 |
zeroPt = 100, |
|
|
494 |
originY = -sceneH + subSea + viewFrameH - zeroPt; |
|
|
495 |
|
|
|
496 |
Y.one('#scene').setStyle('top', originY + 'px'); |
|
|
497 |
|
|
|
498 |
/** |
|
|
499 |
* The Dial's valueChange event is passed to this. |
|
|
500 |
* sets the CSS top value of the pictoral scene of the earth to the hubble. |
|
|
501 |
* This scene is an absolute positioned div inside another div with |
|
|
502 |
* overflow set to hidden. |
|
|
503 |
*/ |
|
|
504 |
setSceneY = function(e) { |
|
|
505 |
Y.one('#scene').setStyle('top', (originY + (e.newVal * 10)) + 'px'); |
|
|
506 |
} |
|
|
507 |
|
|
|
508 |
var dial = new Y.Dial({ |
|
|
509 |
min:-35, |
|
|
510 |
max:559, |
|
|
511 |
stepsPerRevolution:30, |
|
|
512 |
value: 0, |
|
|
513 |
diameter: 100, |
|
|
514 |
minorStep: 1, |
|
|
515 |
majorStep: 10, |
|
|
516 |
decimalPlaces: 2, |
|
|
517 |
strings:{label:'Altitude in Kilometers:', resetStr: 'Reset', tooltipHandle: 'Drag to set'}, |
|
|
518 |
// construction-time event subscription |
|
|
519 |
after : { |
|
|
520 |
valueChange: Y.bind( setSceneY, dial ) |
|
|
521 |
} |
|
|
522 |
}); |
|
|
523 |
dial.render('#demo'); |
|
|
524 |
|
|
|
525 |
// Function that calls a method in Dial that sets its value to the value of the max config attribute |
|
|
526 |
// Other methods available include, |
|
|
527 |
// _setToMin(), _resetDial(), _incrMinor(), _decrMinor(), _incrMajor(), _decrMajor(), |
|
|
528 |
var setDialToMax = function(e){ |
|
|
529 |
e.preventDefault(); |
|
|
530 |
this._setToMax(); |
|
|
531 |
} |
|
|
532 |
|
|
|
533 |
// Subscribe to the click of the "Hubble" anchor, passing the dial as the 'this' |
|
|
534 |
Y.on('click', setDialToMax, '#a-hubble', dial); |
|
|
535 |
|
|
|
536 |
}); |
|
|
537 |
</script> |
|
|
538 |
</html></pre> |
|
|
539 |
|
|
|
540 |
</div> |
|
|
541 |
</div> |
|
|
542 |
</div> |
|
|
543 |
|
|
|
544 |
<div class="yui3-u-1-4"> |
|
|
545 |
<div class="sidebar"> |
|
|
546 |
|
|
|
547 |
<div id="toc" class="sidebox"> |
|
|
548 |
<div class="hd"> |
|
|
549 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
550 |
</div> |
|
|
551 |
|
|
|
552 |
<div class="bd"> |
|
|
553 |
<ul class="toc"> |
|
|
554 |
<li> |
|
|
555 |
<a href="#making-a-dial-drive-an-interactive-ui">Making a Dial Drive an Interactive UI</a> |
|
|
556 |
<ul class="toc"> |
|
|
557 |
<li> |
|
|
558 |
<a href="#the-markup">The Markup</a> |
|
|
559 |
</li> |
|
|
560 |
<li> |
|
|
561 |
<a href="#the-javascript">The JavaScript</a> |
|
|
562 |
<ul class="toc"> |
|
|
563 |
<li> |
|
|
564 |
<a href="#the-event-handler">The Event Handler</a> |
|
|
565 |
</li> |
|
|
566 |
</ul> |
|
|
567 |
</li> |
|
|
568 |
</ul> |
|
|
569 |
</li> |
|
|
570 |
<li> |
|
|
571 |
<a href="#complete-example-source">Complete Example Source</a> |
|
|
572 |
</li> |
|
|
573 |
</ul> |
|
|
574 |
</div> |
|
|
575 |
</div> |
|
|
576 |
|
|
|
577 |
|
|
|
578 |
|
|
|
579 |
<div class="sidebox"> |
|
|
580 |
<div class="hd"> |
|
|
581 |
<h2 class="no-toc">Examples</h2> |
|
|
582 |
</div> |
|
|
583 |
|
|
|
584 |
<div class="bd"> |
|
|
585 |
<ul class="examples"> |
|
|
586 |
|
|
|
587 |
|
|
|
588 |
<li data-description="Create a Dial from existing markup on the page - a simple use case."> |
|
|
589 |
<a href="dial-basic.html">Basic Dial</a> |
|
|
590 |
</li> |
|
|
591 |
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
<li data-description="Link a Dial with a text input field."> |
|
|
595 |
<a href="dial-text-input.html">Dial Linked With Text Input</a> |
|
|
596 |
</li> |
|
|
597 |
|
|
|
598 |
|
|
|
599 |
|
|
|
600 |
<li data-description="Use image backgrounds to control the visual display of a Dial."> |
|
|
601 |
<a href="dial-image-background.html">Dial With Image Background</a> |
|
|
602 |
</li> |
|
|
603 |
|
|
|
604 |
|
|
|
605 |
|
|
|
606 |
<li data-description="Use images to surround a Dial instance and provide additional styling."> |
|
|
607 |
<a href="dial-image-surrounding.html">Dial With a Surrounding Image</a> |
|
|
608 |
</li> |
|
|
609 |
|
|
|
610 |
|
|
|
611 |
|
|
|
612 |
<li data-description="This example employs Dial to drive an interactive UI."> |
|
|
613 |
<a href="dial-interactive.html">Dial With Interactive UI</a> |
|
|
614 |
</li> |
|
|
615 |
|
|
|
616 |
|
|
|
617 |
|
|
|
618 |
<li data-description="This example shows how to use Dial to animate an image sprite."> |
|
|
619 |
<a href="duck.html">Image Sprite Animation with Dial</a> |
|
|
620 |
</li> |
|
|
621 |
|
|
|
622 |
|
|
|
623 |
|
|
|
624 |
|
|
|
625 |
</ul> |
|
|
626 |
</div> |
|
|
627 |
</div> |
|
|
628 |
|
|
|
629 |
|
|
|
630 |
|
|
|
631 |
<div class="sidebox"> |
|
|
632 |
<div class="hd"> |
|
|
633 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
634 |
</div> |
|
|
635 |
|
|
|
636 |
<div class="bd"> |
|
|
637 |
<ul class="examples"> |
|
|
638 |
|
|
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
|
642 |
|
|
|
643 |
|
|
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
|
650 |
|
|
|
651 |
|
|
|
652 |
<li data-description="Use the HSL color picker to select a new color. Then chose the color type you like best."> |
|
|
653 |
<a href="../color/hsl-picker.html">HSL Color Picker</a> |
|
|
654 |
</li> |
|
|
655 |
|
|
|
656 |
|
|
|
657 |
</ul> |
|
|
658 |
</div> |
|
|
659 |
</div> |
|
|
660 |
|
|
|
661 |
</div> |
|
|
662 |
</div> |
|
|
663 |
</div> |
|
|
664 |
</div> |
|
|
665 |
|
|
|
666 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
667 |
<script>prettyPrint();</script> |
|
|
668 |
|
|
|
669 |
<script> |
|
|
670 |
YUI.Env.Tests = { |
|
|
671 |
examples: [], |
|
|
672 |
project: '../assets', |
|
|
673 |
assets: '../assets/dial', |
|
|
674 |
name: 'dial-interactive', |
|
|
675 |
title: 'Dial With Interactive UI', |
|
|
676 |
newWindow: '', |
|
|
677 |
auto: false |
|
|
678 |
}; |
|
|
679 |
YUI.Env.Tests.examples.push('dial-basic'); |
|
|
680 |
YUI.Env.Tests.examples.push('dial-text-input'); |
|
|
681 |
YUI.Env.Tests.examples.push('dial-image-background'); |
|
|
682 |
YUI.Env.Tests.examples.push('dial-image-surrounding'); |
|
|
683 |
YUI.Env.Tests.examples.push('dial-interactive'); |
|
|
684 |
YUI.Env.Tests.examples.push('duck'); |
|
|
685 |
YUI.Env.Tests.examples.push('hsl-picker'); |
|
|
686 |
|
|
|
687 |
</script> |
|
|
688 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
689 |
|
|
|
690 |
|
|
|
691 |
|
|
|
692 |
</body> |
|
|
693 |
</html> |