5
<title>Example: Basic Dial</title>
6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
<link rel="stylesheet" href="../assets/css/main.css">
8
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
<script src="../../build/yui/yui-min.js"></script>
14
<h1>Example: Basic Dial</h1>
17
<a href="#toc" class="jump">Jump to Table of Contents</a>
21
<div id="main" class="yui3-u">
22
<div class="content"><div class="intro">
23
<p>This example shows how to create a basic <code>Dial</code> widget.</p>
25
<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>
28
<div class="example yui3-skin-sam">
40
YUI().use('dial', function(Y) {
42
var dial = new Y.Dial({
45
stepsPerRevolution:100,
55
<h3 id="creating-a-dial">Creating a Dial</h3>
56
<p>A <code>Dial</code> can be created easily and rendered into existing markup.</p>
58
<h4 id="the-markup">The Markup</h4>
59
<p>The only markup requirement is an HTML element to contain the Dial.</p>
61
<pre class="code prettyprint"><div id="demo"></div></pre>
63
<h4 id="the-javascript">The JavaScript</h4>
64
<p><code>Dial</code> extends the <code>Widget</code> class, following the same pattern
65
as any widget constructor. As a result, it accepts a configuration object to
66
set the initial configuration for the widget.</p>
68
<p>After creating and configuring the new <code>Dial</code>,
69
call the <code>render</code> method on the <code>Dial</code> object, passing it
70
the selector for a container element.
71
This renders it into the container and makes it usable.</p>
73
<p>Some commonly used configuration attributes are shown below. </p>
74
<pre class="code prettyprint">YUI().use('dial', function(Y) {
76
var dial = new Y.Dial({
79
stepsPerRevolution:100,
82
dial.render('#demo');
86
<h3 id="complete-example-source">Complete Example Source</h3>
87
<pre class="code prettyprint"><!DOCTYPE HTML>
89
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
91
<body class="yui3-skin-sam">
92
<div id="demo"></div>
96
YUI().use('dial', function(Y) {
98
var dial = new Y.Dial({
101
stepsPerRevolution:100,
104
dial.render('#demo');
108
</html></pre>
114
<div id="sidebar" class="yui3-u">
116
<div id="toc" class="sidebox">
118
<h2 class="no-toc">Table of Contents</h2>
124
<a href="#creating-a-dial">Creating a Dial</a>
127
<a href="#the-markup">The Markup</a>
130
<a href="#the-javascript">The JavaScript</a>
135
<a href="#complete-example-source">Complete Example Source</a>
143
<div class="sidebox">
145
<h2 class="no-toc">Examples</h2>
149
<ul class="examples">
152
<li data-description="Create a Dial from existing markup on the page - a simple use case.">
153
<a href="dial-basic.html">Basic Dial</a>
158
<li data-description="Link a Dial with a text input field.">
159
<a href="dial-text-input.html">Dial Linked With Text Input</a>
164
<li data-description="Use image backgrounds to control the visual display of a Dial.">
165
<a href="dial-image-background.html">Dial With Image Background</a>
170
<li data-description="Use images to surround a Dial instance and provide additional styling.">
171
<a href="dial-image-surrounding.html">Dial With a Surrounding Image</a>
176
<li data-description="This example employs Dial to drive an interactive UI.">
177
<a href="dial-interactive.html">Dial With Interactive UI</a>
191
<script src="../assets/vendor/prettify/prettify-min.js"></script>
192
<script>prettyPrint();</script>