5
<title>Example: Basic Dial</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: Basic Dial</h1>
18
<a href="#toc" class="jump">Jump to Table of Contents</a>
22
<div class="yui3-u-3-4">
24
<div class="content"><div class="intro">
25
<p>This example shows how to create a basic <code>Dial</code> widget.</p>
27
<p>Drag the handle, or click the ring, to set the value. When the handle has the focus, the following keys update its value: arrow keys, page up/down, home, and 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>
30
<div class="example yui3-skin-sam">
42
YUI().use('dial', function(Y) {
44
var dial = new Y.Dial({
47
stepsPerRevolution:100,
57
<h3 id="creating-a-dial">Creating a Dial</h3>
58
<p>A <code>Dial</code> can be created easily and rendered into existing markup.</p>
60
<h4 id="the-markup">The Markup</h4>
61
<p>The only markup requirement is an HTML element to contain the Dial.</p>
63
<pre class="code prettyprint"><div id="demo"></div></pre>
65
<h4 id="the-javascript">The JavaScript</h4>
66
<p><code>Dial</code> extends the <code>Widget</code> class, following the same pattern
67
as any widget constructor. As a result, it accepts a configuration object to
68
set the initial configuration for the widget.</p>
70
<p>After creating and configuring the new <code>Dial</code>,
71
call the <code>render</code> method on the <code>Dial</code> object, passing it
72
the selector for a container element.
73
This renders it into the container and makes it usable.</p>
75
<p>Some commonly used configuration attributes are shown below. </p>
76
<pre class="code prettyprint">YUI().use('dial', function(Y) {
78
var dial = new Y.Dial({
81
stepsPerRevolution:100,
84
dial.render('#demo');
88
<h3 id="complete-example-source">Complete Example Source</h3>
89
<pre class="code prettyprint"><!DOCTYPE HTML>
91
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
93
<body class="yui3-skin-sam">
94
<div id="demo"></div>
98
YUI().use('dial', function(Y) {
100
var dial = new Y.Dial({
103
stepsPerRevolution:100,
106
dial.render('#demo');
110
</html></pre>
117
<div class="yui3-u-1-4">
118
<div class="sidebar">
120
<div id="toc" class="sidebox">
122
<h2 class="no-toc">Table of Contents</h2>
128
<a href="#creating-a-dial">Creating a Dial</a>
131
<a href="#the-markup">The Markup</a>
134
<a href="#the-javascript">The JavaScript</a>
139
<a href="#complete-example-source">Complete Example Source</a>
147
<div class="sidebox">
149
<h2 class="no-toc">Examples</h2>
153
<ul class="examples">
156
<li data-description="Create a Dial from existing markup on the page - a simple use case.">
157
<a href="dial-basic.html">Basic Dial</a>
162
<li data-description="Link a Dial with a text input field.">
163
<a href="dial-text-input.html">Dial Linked With Text Input</a>
168
<li data-description="Use image backgrounds to control the visual display of a Dial.">
169
<a href="dial-image-background.html">Dial With Image Background</a>
174
<li data-description="Use images to surround a Dial instance and provide additional styling.">
175
<a href="dial-image-surrounding.html">Dial With a Surrounding Image</a>
180
<li data-description="This example employs Dial to drive an interactive UI.">
181
<a href="dial-interactive.html">Dial With Interactive UI</a>
186
<li data-description="This example shows how to use Dial to animate an image sprite.">
187
<a href="duck.html">Image Sprite Animation with Dial</a>
202
<script src="../assets/vendor/prettify/prettify-min.js"></script>
203
<script>prettyPrint();</script>