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