src/cm/media/js/lib/yui/yui_3.10.3/docs/dial/dial-basic.html
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 525 89ef5ed3c48b
permissions -rw-r--r--
add link to "privacy policy" in the header test

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Basic Dial</title>
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
    <link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
    <script src="../../build/yui/yui-min.js"></script>
    
</head>
<body>
<!--
<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>
-->
<div id="doc">
    <div id="hd">
        <h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1>
    </div>
    
        <a href="#toc" class="jump">Jump to Table of Contents</a>
    

            <h1>Example: Basic Dial</h1>
    <div class="yui3-g">
        <div class="yui3-u-3-4">
            <div id="main">
                <div class="content"><div class="intro">
    <p>This example shows how to create a basic <code>Dial</code> widget.</p>
    
    <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>
</div>

<div class="example yui3-skin-sam">
    <style>
    #demo {
        margin:0 0 1em;
    }
    .example {
        text-align: center;
        *text-align: left;
    }
</style>
<div id="demo"></div>
<script>
YUI().use('dial', function(Y) {

    var dial = new Y.Dial({
        min:-220,
        max:220,
        stepsPerRevolution:100,
        value: 30
    });
    dial.render('#demo');

});
</script>

</div>

<h3 id="creating-a-dial">Creating a Dial</h3>
<p>A <code>Dial</code> can be created easily and rendered into existing markup.</p>

<h4 id="the-markup">The Markup</h4>
<p>
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the
page's <code>&lt;body&gt;</code> element or to a parent element of the widget in order to apply
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>.
</p>
<pre class="code prettyprint">&lt;body class=&quot;yui3-skin-sam&quot;&gt; &lt;!-- You need this skin class --&gt;</pre>

<p>The only markup requirement is an HTML element to contain the Dial.</p>

<pre class="code prettyprint">&lt;div id=&quot;demo&quot;&gt;&lt;&#x2F;div&gt;</pre>

<h4 id="the-javascript">The JavaScript</h4>
<p><code>Dial</code> extends the <code>Widget</code> class, following the same pattern 
as any widget constructor.  As a result, it accepts a configuration object to 
set the initial configuration for the widget.</p>

<p>After creating and configuring the new <code>Dial</code>, 
call the <code>render</code> method on the <code>Dial</code> object, passing it
the selector for a container element. 
This renders it into the container and makes it usable.</p>

<p>Some commonly used configuration attributes are shown below. </p>
<pre class="code prettyprint">YUI().use(&#x27;dial&#x27;, function(Y) {

    var dial = new Y.Dial({
        min:-220,
        max:220,
        stepsPerRevolution:100,
        value: 30
    });
    dial.render(&#x27;#demo&#x27;);

});</pre>

<h3 id="complete-example-source">Complete Example Source</h3>
<pre class="code prettyprint">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;script src=&quot;http:&#x2F;&#x2F;yui.yahooapis.com&#x2F;3.10.3&#x2F;build&#x2F;yui&#x2F;yui-min.js&quot;&gt;&lt;&#x2F;script&gt;

&lt;body class=&quot;yui3-skin-sam&quot;&gt; &lt;!-- You need this skin class --&gt;
    &lt;div id=&quot;demo&quot;&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;body&gt;

&lt;script&gt;
YUI().use(&#x27;dial&#x27;, function(Y) {

    var dial = new Y.Dial({
        min:-220,
        max:220,
        stepsPerRevolution:100,
        value: 30
    });
    dial.render(&#x27;#demo&#x27;);

});
&lt;&#x2F;script&gt;
&lt;&#x2F;html&gt;</pre>


</div>
            </div>
        </div>

        <div class="yui3-u-1-4">
            <div class="sidebar">
                
                    <div id="toc" class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Table of Contents</h2>
                        </div>

                        <div class="bd">
                            <ul class="toc">
<li>
<a href="#creating-a-dial">Creating a Dial</a>
<ul class="toc">
<li>
<a href="#the-markup">The Markup</a>
</li>
<li>
<a href="#the-javascript">The JavaScript</a>
</li>
</ul>
</li>
<li>
<a href="#complete-example-source">Complete Example Source</a>
</li>
</ul>
                        </div>
                    </div>
                

                
                    <div class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Examples</h2>
                        </div>

                        <div class="bd">
                            <ul class="examples">
                                
                                    
                                        <li data-description="Create a Dial from existing markup on the page - a simple use case.">
                                            <a href="dial-basic.html">Basic Dial</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Link a Dial with a text input field.">
                                            <a href="dial-text-input.html">Dial Linked With Text Input</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Use image backgrounds to control the visual display of a Dial.">
                                            <a href="dial-image-background.html">Dial With Image Background</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="Use images to surround a Dial instance and provide additional styling.">
                                            <a href="dial-image-surrounding.html">Dial With a Surrounding Image</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="This example employs Dial to drive an interactive UI.">
                                            <a href="dial-interactive.html">Dial With Interactive UI</a>
                                        </li>
                                    
                                
                                    
                                        <li data-description="This example shows how to use Dial to animate an image sprite.">
                                            <a href="duck.html">Image Sprite Animation with Dial</a>
                                        </li>
                                    
                                
                                    
                                
                            </ul>
                        </div>
                    </div>
                

                
                    <div class="sidebox">
                        <div class="hd">
                            <h2 class="no-toc">Examples That Use This Component</h2>
                        </div>

                        <div class="bd">
                            <ul class="examples">
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                
                                    
                                        <li data-description="Use the HSL color picker to select a new color. Then chose the color type you like best.">
                                            <a href="../color/hsl-picker.html">HSL Color Picker</a>
                                        </li>
                                    
                                
                            </ul>
                        </div>
                    </div>
                
            </div>
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

<script>
YUI.Env.Tests = {
    examples: [],
    project: '../assets',
    assets: '../assets/dial',
    name: 'dial-basic',
    title: 'Basic Dial',
    newWindow: '',
    auto:  false 
};
YUI.Env.Tests.examples.push('dial-basic');
YUI.Env.Tests.examples.push('dial-text-input');
YUI.Env.Tests.examples.push('dial-image-background');
YUI.Env.Tests.examples.push('dial-image-surrounding');
YUI.Env.Tests.examples.push('dial-interactive');
YUI.Env.Tests.examples.push('duck');
YUI.Env.Tests.examples.push('hsl-picker');

</script>
<script src="../assets/yui/test-runner.js"></script>



</body>
</html>