|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Dial With a Surrounding Image</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 a Surrounding Image</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 example shows how to create a <code>Dial</code> widget using an image |
|
|
32 |
that surrounds (or is larger than) the Dial.</p> |
|
|
33 |
</div> |
|
|
34 |
|
|
|
35 |
<div class="example yui3-skin-sam"> |
|
|
36 |
<style type="text/css"> |
|
|
37 |
.example { |
|
|
38 |
text-align:center; |
|
|
39 |
*text-align: left; |
|
|
40 |
} |
|
|
41 |
/* Adding some margin to allow for the image */ |
|
|
42 |
.yui3-dial{ |
|
|
43 |
margin:0 0 20px 20px; |
|
|
44 |
} |
|
|
45 |
|
|
|
46 |
/* Here, we are just cleaning out the visible |
|
|
47 |
styles of the ring and the center button |
|
|
48 |
to allow for the images. */ |
|
|
49 |
|
|
|
50 |
/* Remove visible styles of the ring */ |
|
|
51 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring{ |
|
|
52 |
box-shadow: none; |
|
|
53 |
-moz-border-radius: none; |
|
|
54 |
-webkit-border-radius: none; |
|
|
55 |
-moz-box-shadow: none; |
|
|
56 |
-webkit-box-shadow: none; |
|
|
57 |
background:none; |
|
|
58 |
} |
|
|
59 |
|
|
|
60 |
/* Remove visible style of the center button */ |
|
|
61 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button { |
|
|
62 |
box-shadow: none; |
|
|
63 |
-moz-border-radius: none; |
|
|
64 |
-webkit-border-radius: none; |
|
|
65 |
-moz-box-shadow: none; |
|
|
66 |
background:none; |
|
|
67 |
} |
|
|
68 |
|
|
|
69 |
/* Hide all VML ovals in IE. */ |
|
|
70 |
.yui3-skin-sam .yui3-dial-ring-vml v\:oval { |
|
|
71 |
visibility:hidden; |
|
|
72 |
} |
|
|
73 |
|
|
|
74 |
/* Show the marker and the handle ovals */ |
|
|
75 |
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-marker-vml v\:oval, |
|
|
76 |
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-handle-vml v\:oval { |
|
|
77 |
visibility:visible; |
|
|
78 |
} |
|
|
79 |
|
|
|
80 |
/* Fill center button and ring so their backgrounds accept events in IE */ |
|
|
81 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button-vml, |
|
|
82 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring-vml{ |
|
|
83 |
background:url(../assets/dial/images/empty.png); |
|
|
84 |
} |
|
|
85 |
</style> |
|
|
86 |
|
|
|
87 |
<div id="demo"></div> |
|
|
88 |
|
|
|
89 |
<script> |
|
|
90 |
YUI().use('dial', function(Y) { |
|
|
91 |
|
|
|
92 |
var dial = new Y.Dial({ |
|
|
93 |
min: -90, |
|
|
94 |
max: 90, |
|
|
95 |
stepsPerRevolution: 200, |
|
|
96 |
value: 0, |
|
|
97 |
diameter: 100 |
|
|
98 |
}); |
|
|
99 |
dial.set('strings',{'label':'Climate:', 'resetStr':'Off', 'tooltipHandle':'Drag for cool or heat.'}); |
|
|
100 |
dial.render('#demo'); |
|
|
101 |
|
|
|
102 |
var im = Y.Node.create('<img src="http://yuilibrary.com/yui/docs/assets/dial/images/cold_hot.png"/>'); |
|
|
103 |
im.setStyles({'position':'absolute', 'top':'-3px', 'left':'-9px'}); |
|
|
104 |
Y.one('.yui3-dial-north-mark').insert(im, 'before'); |
|
|
105 |
|
|
|
106 |
}); |
|
|
107 |
</script> |
|
|
108 |
</div> |
|
|
109 |
|
|
|
110 |
<h3 id="creating-a-dial-and-surrounding-it-with-a-larger-image">Creating a Dial and Surrounding It With a Larger Image</h3> |
|
|
111 |
|
|
|
112 |
<p>Some cases may require a <code>Dial</code> that has an image surrounding it such as tick marks, units, or other |
|
|
113 |
visual enhancements. These images can be larger than the ring of the dial and therefore may not fit as a background image. |
|
|
114 |
To provide for this use case, an extra image object will need to be added to the DOM.</p> |
|
|
115 |
|
|
|
116 |
<p> |
|
|
117 |
In this example we'll simulate the climate control on an car dashboard. |
|
|
118 |
The image we'll add contains two curved wedges of color, blue and red, that wrap around the dial, |
|
|
119 |
signifying the temperature of air conditioning or heat. |
|
|
120 |
</p> |
|
|
121 |
|
|
|
122 |
<h4 id="the-markup">The Markup</h4> |
|
|
123 |
<p> |
|
|
124 |
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the |
|
|
125 |
page's <code><body></code> element or to a parent element of the widget in order to apply |
|
|
126 |
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>. |
|
|
127 |
</p> |
|
|
128 |
<pre class="code prettyprint"><body class="yui3-skin-sam"> <!-- You need this skin class --></pre> |
|
|
129 |
|
|
|
130 |
<p>The only markup requirement is a div to contain the <code>Dial</code>.</p> |
|
|
131 |
|
|
|
132 |
<pre class="code prettyprint"><div id="demo"></div></pre> |
|
|
133 |
|
|
|
134 |
|
|
|
135 |
<h4 id="the-javascript">The JavaScript</h4> |
|
|
136 |
|
|
|
137 |
<p>The same JavaScript can be used as in the basic Dial example, with a bit of |
|
|
138 |
extra code to add the image object.</p> |
|
|
139 |
|
|
|
140 |
<p>Some commonly used configuration attributes are shown below. |
|
|
141 |
This example also shows how to modify the visible UI strings before the <code>Dial</code> renders.</p> |
|
|
142 |
<pre class="code prettyprint">YUI().use('dial', function(Y) { |
|
|
143 |
|
|
|
144 |
var dial = new Y.Dial({ |
|
|
145 |
min: -90, |
|
|
146 |
max: 90, |
|
|
147 |
stepsPerRevolution: 200, |
|
|
148 |
value: 0, |
|
|
149 |
diameter: 100 |
|
|
150 |
}); |
|
|
151 |
//Setting visible HTML strings before Dial renders. |
|
|
152 |
dial.set('strings',{'label':'Climate:', 'resetStr':'Off', 'tooltipHandle':'Drag for cool or heat.'}); |
|
|
153 |
dial.render("#demo"); |
|
|
154 |
|
|
|
155 |
});</pre> |
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
<h4 id="inserting-the-image">Inserting the Image</h4> |
|
|
160 |
<p>After rendering the <code>Dial</code>, we create and insert the image object.</p> |
|
|
161 |
<pre class="code prettyprint">//Create an image node. |
|
|
162 |
var im = Y.Node.create('<img src="http://yuilibrary.com/yui/docs/assets/dial/images/cold_hot.png"/>'); |
|
|
163 |
|
|
|
164 |
//Position it absolutely to the correct spot depending on it's size. |
|
|
165 |
im.setStyles({'position':'absolute', 'top':'-3px', 'left':'-9px'}); |
|
|
166 |
|
|
|
167 |
//Insert it in the DOM. |
|
|
168 |
//The north-mark is the first object inside the ring. |
|
|
169 |
//depending on the image, you may need to insert it before the yui3-dial-label |
|
|
170 |
Y.one('.yui3-dial-north-mark').insert(im, 'before');</pre> |
|
|
171 |
|
|
|
172 |
|
|
|
173 |
<h4 id="the-css">The CSS</h4> |
|
|
174 |
<p> |
|
|
175 |
In the CSS, we're just cleaning out the visible styles of the ring and the |
|
|
176 |
center button to allow for the images. |
|
|
177 |
</p> |
|
|
178 |
|
|
|
179 |
<h3 id="complete-example-source">Complete Example Source</h3> |
|
|
180 |
<pre class="code prettyprint"><!DOCTYPE HTML> |
|
|
181 |
<html> |
|
|
182 |
<script src="http://yui.yahooapis.com/3.10.3/build/yui/yui-min.js"></script> |
|
|
183 |
|
|
|
184 |
<style> |
|
|
185 |
/* Adding some margin to allow for the image */ |
|
|
186 |
.yui3-dial{ |
|
|
187 |
margin:0 0 20px 20px; |
|
|
188 |
} |
|
|
189 |
|
|
|
190 |
/* Here, we are just cleaning out the visible |
|
|
191 |
styles of the ring and the center button |
|
|
192 |
to allow for the images. */ |
|
|
193 |
|
|
|
194 |
/* Remove visible styles of the ring */ |
|
|
195 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring{ |
|
|
196 |
box-shadow: none; |
|
|
197 |
-moz-border-radius: none; |
|
|
198 |
-webkit-border-radius: none; |
|
|
199 |
-moz-box-shadow: none; |
|
|
200 |
-webkit-box-shadow: none; |
|
|
201 |
background:none; |
|
|
202 |
} |
|
|
203 |
|
|
|
204 |
/* Remove visible style of the center button */ |
|
|
205 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button { |
|
|
206 |
box-shadow: none; |
|
|
207 |
-moz-border-radius: none; |
|
|
208 |
-webkit-border-radius: none; |
|
|
209 |
-moz-box-shadow: none; |
|
|
210 |
background:none; |
|
|
211 |
} |
|
|
212 |
|
|
|
213 |
/* Hide all VML ovals in IE. */ |
|
|
214 |
.yui3-skin-sam .yui3-dial-ring-vml v\:oval { |
|
|
215 |
visibility:hidden; |
|
|
216 |
} |
|
|
217 |
|
|
|
218 |
/* Show the marker and the handle ovals */ |
|
|
219 |
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-marker-vml v\:oval, |
|
|
220 |
.yui3-skin-sam .yui3-dial-ring-vml .yui3-dial-handle-vml v\:oval { |
|
|
221 |
visibility:visible; |
|
|
222 |
} |
|
|
223 |
|
|
|
224 |
/* Fill center button and ring so their backgrounds accept events in IE */ |
|
|
225 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-center-button-vml, |
|
|
226 |
.yui3-skin-sam .yui3-dial-content .yui3-dial-ring-vml{ |
|
|
227 |
background:url(../assets/dial/images/empty.png); |
|
|
228 |
} |
|
|
229 |
</style> |
|
|
230 |
|
|
|
231 |
<body class="yui3-skin-sam"> <!-- You need this skin class --> |
|
|
232 |
<div id="demo"></div> |
|
|
233 |
</body> |
|
|
234 |
|
|
|
235 |
<script> |
|
|
236 |
YUI().use('dial', function(Y) { |
|
|
237 |
|
|
|
238 |
var dial = new Y.Dial({ |
|
|
239 |
min: -90, |
|
|
240 |
max: 90, |
|
|
241 |
stepsPerRevolution: 200, |
|
|
242 |
value: 0, |
|
|
243 |
diameter: 100 |
|
|
244 |
}); |
|
|
245 |
dial.set('strings',{'label':'Climate:', 'resetStr':'Off', 'tooltipHandle':'Drag for cool or heat.'}); |
|
|
246 |
dial.render('#demo'); |
|
|
247 |
|
|
|
248 |
var im = Y.Node.create('<img src="http://yuilibrary.com/yui/docs/assets/dial/images/cold_hot.png"/>'); |
|
|
249 |
im.setStyles({'position':'absolute', 'top':'-3px', 'left':'-9px'}); |
|
|
250 |
Y.one('.yui3-dial-north-mark').insert(im, 'before'); |
|
|
251 |
|
|
|
252 |
}); |
|
|
253 |
</script> |
|
|
254 |
</html></pre> |
|
|
255 |
|
|
|
256 |
</div> |
|
|
257 |
</div> |
|
|
258 |
</div> |
|
|
259 |
|
|
|
260 |
<div class="yui3-u-1-4"> |
|
|
261 |
<div class="sidebar"> |
|
|
262 |
|
|
|
263 |
<div id="toc" class="sidebox"> |
|
|
264 |
<div class="hd"> |
|
|
265 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
266 |
</div> |
|
|
267 |
|
|
|
268 |
<div class="bd"> |
|
|
269 |
<ul class="toc"> |
|
|
270 |
<li> |
|
|
271 |
<a href="#creating-a-dial-and-surrounding-it-with-a-larger-image">Creating a Dial and Surrounding It With a Larger Image</a> |
|
|
272 |
<ul class="toc"> |
|
|
273 |
<li> |
|
|
274 |
<a href="#the-markup">The Markup</a> |
|
|
275 |
</li> |
|
|
276 |
<li> |
|
|
277 |
<a href="#the-javascript">The JavaScript</a> |
|
|
278 |
</li> |
|
|
279 |
<li> |
|
|
280 |
<a href="#inserting-the-image">Inserting the Image</a> |
|
|
281 |
</li> |
|
|
282 |
<li> |
|
|
283 |
<a href="#the-css">The CSS</a> |
|
|
284 |
</li> |
|
|
285 |
</ul> |
|
|
286 |
</li> |
|
|
287 |
<li> |
|
|
288 |
<a href="#complete-example-source">Complete Example Source</a> |
|
|
289 |
</li> |
|
|
290 |
</ul> |
|
|
291 |
</div> |
|
|
292 |
</div> |
|
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
<div class="sidebox"> |
|
|
297 |
<div class="hd"> |
|
|
298 |
<h2 class="no-toc">Examples</h2> |
|
|
299 |
</div> |
|
|
300 |
|
|
|
301 |
<div class="bd"> |
|
|
302 |
<ul class="examples"> |
|
|
303 |
|
|
|
304 |
|
|
|
305 |
<li data-description="Create a Dial from existing markup on the page - a simple use case."> |
|
|
306 |
<a href="dial-basic.html">Basic Dial</a> |
|
|
307 |
</li> |
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
<li data-description="Link a Dial with a text input field."> |
|
|
312 |
<a href="dial-text-input.html">Dial Linked With Text Input</a> |
|
|
313 |
</li> |
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
<li data-description="Use image backgrounds to control the visual display of a Dial."> |
|
|
318 |
<a href="dial-image-background.html">Dial With Image Background</a> |
|
|
319 |
</li> |
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
<li data-description="Use images to surround a Dial instance and provide additional styling."> |
|
|
324 |
<a href="dial-image-surrounding.html">Dial With a Surrounding Image</a> |
|
|
325 |
</li> |
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
<li data-description="This example employs Dial to drive an interactive UI."> |
|
|
330 |
<a href="dial-interactive.html">Dial With Interactive UI</a> |
|
|
331 |
</li> |
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
<li data-description="This example shows how to use Dial to animate an image sprite."> |
|
|
336 |
<a href="duck.html">Image Sprite Animation with Dial</a> |
|
|
337 |
</li> |
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
</ul> |
|
|
343 |
</div> |
|
|
344 |
</div> |
|
|
345 |
|
|
|
346 |
|
|
|
347 |
|
|
|
348 |
<div class="sidebox"> |
|
|
349 |
<div class="hd"> |
|
|
350 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
351 |
</div> |
|
|
352 |
|
|
|
353 |
<div class="bd"> |
|
|
354 |
<ul class="examples"> |
|
|
355 |
|
|
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|
363 |
|
|
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
|
369 |
<li data-description="Use the HSL color picker to select a new color. Then chose the color type you like best."> |
|
|
370 |
<a href="../color/hsl-picker.html">HSL Color Picker</a> |
|
|
371 |
</li> |
|
|
372 |
|
|
|
373 |
|
|
|
374 |
</ul> |
|
|
375 |
</div> |
|
|
376 |
</div> |
|
|
377 |
|
|
|
378 |
</div> |
|
|
379 |
</div> |
|
|
380 |
</div> |
|
|
381 |
</div> |
|
|
382 |
|
|
|
383 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
384 |
<script>prettyPrint();</script> |
|
|
385 |
|
|
|
386 |
<script> |
|
|
387 |
YUI.Env.Tests = { |
|
|
388 |
examples: [], |
|
|
389 |
project: '../assets', |
|
|
390 |
assets: '../assets/dial', |
|
|
391 |
name: 'dial-image-surrounding', |
|
|
392 |
title: 'Dial With a Surrounding Image', |
|
|
393 |
newWindow: '', |
|
|
394 |
auto: false |
|
|
395 |
}; |
|
|
396 |
YUI.Env.Tests.examples.push('dial-basic'); |
|
|
397 |
YUI.Env.Tests.examples.push('dial-text-input'); |
|
|
398 |
YUI.Env.Tests.examples.push('dial-image-background'); |
|
|
399 |
YUI.Env.Tests.examples.push('dial-image-surrounding'); |
|
|
400 |
YUI.Env.Tests.examples.push('dial-interactive'); |
|
|
401 |
YUI.Env.Tests.examples.push('duck'); |
|
|
402 |
YUI.Env.Tests.examples.push('hsl-picker'); |
|
|
403 |
|
|
|
404 |
</script> |
|
|
405 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
406 |
|
|
|
407 |
|
|
|
408 |
|
|
|
409 |
</body> |
|
|
410 |
</html> |