src/cm/media/js/lib/yui/yui_3.10.3/docs/node-focusmanager/node-focusmanager-toolbar.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
525
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     1
<!DOCTYPE html>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     2
<html lang="en">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     3
<head>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     4
    <meta charset="utf-8">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     5
    <title>Example: Accessible Toolbar</title>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     6
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     7
    <link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     8
    <link rel="stylesheet" href="../assets/css/main.css">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
     9
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    10
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    11
    <script src="../../build/yui/yui-min.js"></script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    12
    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    13
</head>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    14
<body>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    15
<!--
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    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>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    17
-->
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    18
<div id="doc">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    19
    <div id="hd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    20
        <h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    21
    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    22
    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    23
        <a href="#toc" class="jump">Jump to Table of Contents</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    24
    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    25
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    26
            <h1>Example: Accessible Toolbar</h1>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    27
    <div class="yui3-g">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    28
        <div class="yui3-u-3-4">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    29
            <div id="main">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    30
                <div class="content"><div class="intro">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    31
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    32
This example illustrates how to create an accessible toolbar using the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    33
Focus Manager Node Plugin and Node's support for the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    34
<a href="http://www.w3.org/TR/wai-aria/">WAI-ARIA Roles and States</a>.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    35
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    36
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    37
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    38
<div class="example">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    39
    <style scoped>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    40
    .yui3-toolbar {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    41
        border: solid 1px #999;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    42
        background-color: #ccc;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    43
        margin: .25em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    44
        overflow: auto;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    45
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    46
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    47
    .yui3-toolbar-button {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    48
        display: inline-block;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    49
        border-width: 1px 0;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    50
        border-style: solid;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    51
        border-color: #808080;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    52
        background-color: #dfdfdf;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    53
        margin: .25em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    54
        font-size: 85%;  /* 11px */
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    55
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    56
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    57
    .first-child {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    58
        margin-left: .5em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    59
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    60
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    61
    .yui3-toolbar-button span {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    62
        display: inline-block;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    63
        border-width: 0 1px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    64
        border-style: solid;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    65
        border-color: #808080;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    66
        margin: 0 -1px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    67
        *position: relative;    /* Necessary to get negative margins working in IE */
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    68
        *left: -1px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    69
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    70
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    71
    .yui3-toolbar-button span span {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    72
        display: inline-block;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    73
        border: solid 1px #b6b6b6;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    74
        margin: 0;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    75
        *position: static;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    76
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    77
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    78
    .yui3-toolbar-button input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    79
        border: none;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    80
        margin: 0;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    81
        padding: 4px 4px 4px 24px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    82
        *overflow: visible; /* Remove superfluous padding for IE */
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    83
        background: transparent url(../assets/node-focusmanager/icons.png) no-repeat;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    84
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    85
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    86
    #add-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    87
        background-position: 4px -102px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    88
        *background-position: 4px -100px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    89
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    90
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    91
    #edit-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    92
        background-position: 4px -78px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    93
        *background-position: 4px -76px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    94
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    95
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    96
    #print-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    97
        background-position: 4px -54px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    98
        *background-position: 4px -52px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
    99
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   100
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   101
    #open-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   102
        background-position: 4px -30px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   103
        *background-position: 4px -28px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   104
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   105
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   106
    #delete-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   107
        background-position: 4px -126px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   108
        *background-position: 4px -124px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   109
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   110
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   111
    #save-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   112
        background-position: 4px -6px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   113
        *background-position: 4px -4px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   114
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   115
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   116
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   117
    /*  Augment the browser's default styling of the focus state by changing the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   118
        background color of the button when it is focused.  */
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   119
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   120
    .yui3-toolbar-button input.focus {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   121
        background-color: #B3D4FF;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   122
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   123
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   124
    #out {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   125
        border: 1px solid #CCC;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   126
        padding: 1em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   127
        margin-top: 10px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   128
    }
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   129
    </style>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   130
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   131
    <div id="toolbar-1" class="yui3-toolbar">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   132
    <span id="add-btn" class="yui3-toolbar-button first-child"><span><span><input type="button" name="btn-add" value="Add"></span></span></span>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   133
    <span id="edit-btn" class="yui3-toolbar-button"><span><span><input type="button" name="btn-edit" value="Edit"></span></span></span>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   134
    <span id="print-btn" class="yui3-toolbar-button"><span><span><input type="button" name="btn-print" value="Print"></span></span></span>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   135
    <span id="delete-btn" class="yui3-toolbar-button"><span><span><input type="button" name="btn-delete" value="Delete"></span></span></span>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   136
    <span id="open-btn" class="yui3-toolbar-button"><span><span><input type="button" name="btn-open" value="Open"></span></span></span>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   137
    <span id="save-btn" class="yui3-toolbar-button"><span><span><input type="button" name="btn-save" value="Save"></span></span></span>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   138
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   139
<div id="out">(Accessible Toolbar results here)</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   140
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   141
<script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   142
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   143
    YUI().use("node-focusmanager", function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   144
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   145
        //  Retrieve the Node instance representing the toolbar
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   146
        //  (<div id="toolbar">) and call the "plug" method
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   147
        //  passing in a reference to the Focus Manager Node Plugin.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   148
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   149
        var toolbar = Y.one("#toolbar-1"),
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   150
            out     = Y.one("#out");
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   151
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   152
        toolbar.plug(Y.Plugin.NodeFocusManager, {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   153
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   154
                descendants: "input",
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   155
                keys: { next: "down:39", // Right arrow
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   156
                        previous: "down:37" },  //  Left arrow
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   157
                focusClass: "focus",
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   158
                circular: true
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   159
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   160
             });
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   161
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   162
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   163
        //  Set the ARIA "role" attribute of the Node instance representing the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   164
        //  toolbar to "toolbar" to improve the semantics of the markup for
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   165
        //  users of screen readers.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   166
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   167
        toolbar.set("role", "toolbar");
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   168
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   169
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   170
        //  Listen for the click event on each button via the use of the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   171
        //  "delegate" method
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   172
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   173
        toolbar.delegate("click", function (event) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   174
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   175
            out.setHTML("You clicked " + this.one("input").get("value"));
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   176
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   177
        }, ".yui3-toolbar-button");
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   178
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   179
    });
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   180
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   181
</script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   182
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   183
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   184
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   185
<h2 id="setting-up-the-html">Setting Up the HTML</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   186
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   187
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   188
Start with a set of <code>&#60;input&#62;</code> elements.  For the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   189
purpose of this example, the <code>type</code> attribute of each
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   190
button will be set to a value of "button" since they won't be responsible for
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   191
submitting a form.  Each <code>&#60;input&#62;</code> is wrapped by two
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   192
<code>&#60;span&#62;</code>s that serve as decorator elements used to style
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   193
each button with rounded corners.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   194
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   195
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   196
<pre class="code prettyprint">&lt;div id=&quot;toolbar-1&quot; class=&quot;yui3-toolbar&quot;&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   197
    &lt;span id=&quot;add-btn&quot; class=&quot;yui3-toolbar-button first-child&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-add&quot; value=&quot;Add&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   198
    &lt;span id=&quot;edit-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-edit&quot; value=&quot;Edit&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   199
    &lt;span id=&quot;print-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-print&quot; value=&quot;Print&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   200
    &lt;span id=&quot;delete-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-delete&quot; value=&quot;Delete&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   201
    &lt;span id=&quot;open-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-open&quot; value=&quot;Open&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   202
    &lt;span id=&quot;save-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-save&quot; value=&quot;Save&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   203
&lt;&#x2F;div&gt;</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   204
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   205
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   206
<h2 id="setting-up-the-css">Setting Up the CSS</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   207
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   208
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   209
Next, each button in the toolbar is styled with rounded corners using a
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   210
combination of the CSS <code>border</code> property along with the use of
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   211
negative margins.  An icon is added to each button using a background image.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   212
Following the advice of the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   213
<a href="http://developer.yahoo.com/performance/rules.html">Exceptional Performance team</a>,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   214
this example uses the technique of
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   215
<a href="http://www.alistapart.com/articles/sprites">CSS Sprites</a>,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   216
combining all of the icons for each button into a single image to reduce
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   217
HTTP requests.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   218
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   219
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   220
<pre class="code prettyprint">.yui3-toolbar {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   221
    border: solid 1px #999;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   222
    background-color: #ccc;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   223
    margin: .25em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   224
    overflow: auto;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   225
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   226
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   227
.yui3-toolbar-button {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   228
    display: inline-block;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   229
    border-width: 1px 0;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   230
    border-style: solid;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   231
    border-color: #808080;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   232
    background-color: #dfdfdf;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   233
    margin: .25em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   234
    font-size: 85%;  &#x2F;* 11px *&#x2F;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   235
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   236
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   237
.first-child {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   238
    margin-left: .5em;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   239
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   240
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   241
.yui3-toolbar-button span {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   242
    display: inline-block;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   243
    border-width: 0 1px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   244
    border-style: solid;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   245
    border-color: #808080;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   246
    margin: 0 -1px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   247
    *position: relative;    &#x2F;* Necessary to get negative margins working in IE *&#x2F;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   248
    *left: -1px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   249
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   250
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   251
.yui3-toolbar-button span span {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   252
    display: inline-block;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   253
    border: solid 1px #b6b6b6;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   254
    margin: 0;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   255
    *position: static;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   256
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   257
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   258
.yui3-toolbar-button input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   259
    border: none;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   260
    margin: 0;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   261
    padding: 4px 4px 4px 24px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   262
    *overflow: visible; &#x2F;* Remove superfluous padding for IE *&#x2F;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   263
    background: transparent url(..&#x2F;assets&#x2F;node-focusmanager&#x2F;icons.png) no-repeat;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   264
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   265
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   266
#add-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   267
    background-position: 4px -102px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   268
    *background-position: 4px -100px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   269
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   270
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   271
#edit-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   272
    background-position: 4px -78px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   273
    *background-position: 4px -76px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   274
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   275
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   276
#print-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   277
    background-position: 4px -54px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   278
    *background-position: 4px -52px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   279
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   280
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   281
#open-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   282
    background-position: 4px -30px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   283
    *background-position: 4px -28px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   284
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   285
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   286
#delete-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   287
    background-position: 4px -126px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   288
    *background-position: 4px -124px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   289
}
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   290
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   291
#save-btn input {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   292
    background-position: 4px -6px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   293
    *background-position: 4px -4px;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   294
}</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   295
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   296
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   297
<h2 id="initializing-the-focus-manager">Initializing the Focus Manager</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   298
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   299
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   300
With the toolbar markup and CSS in place, retrieve the Node instance
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   301
representing the toolbar (<code>&#60;div id="toolbar-1"&#62;</code>)
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   302
and call the <a href="http://yuilibrary.com/yui/docs/api/classes/Node.html#method_plug"><code>plug</code></a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   303
passing in a reference to the Focus Manager Node Plugin as the first argument,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   304
and a collection of configuration attributes as the second argument.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   305
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   306
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   307
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   308
The Focus Manager's
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   309
<a href="http://yuilibrary.com/yui/docs/api/classes/plugin.NodeFocusManager.html#attr_descendants"><code>descendants</code></a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   310
attribute is set to a value of "input", so that only one button in the toolbar
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   311
is in the browser's default tab flow.  This allows users navigating via the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   312
keyboard to use the tab key to quickly move into and out of the toolbar.  Once
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   313
the toolbar has focus, the user can move focus among each button using the left
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   314
and right arrows keys, as defined by the value of the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   315
<a href="http://yuilibrary.com/yui/docs/api/classes/plugin.NodeFocusManager.html#attr_keys"><code>keys</code></a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   316
attribute.  Lastly, the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   317
<a href="http://yuilibrary.com/yui/docs/api/classes/plugin.NodeFocusManager.html#attr_focusClass"><code>focusClass</code></a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   318
attribute is used to apply a class of <code>focus</code> to each
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   319
<code>&#60;input&#62;</code> when it is focused, making it easy to style the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   320
focused state in all browsers.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   321
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   322
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   323
<pre class="code prettyprint">YUI().use(&quot;node-focusmanager&quot;, function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   324
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   325
    &#x2F;&#x2F;  Retrieve the Node instance representing the toolbar
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   326
    &#x2F;&#x2F;  (&lt;div id=&quot;toolbar&quot;&gt;) and call the &quot;plug&quot; method
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   327
    &#x2F;&#x2F;  passing in a reference to the Focus Manager Node Plugin.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   328
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   329
    var toolbar = Y.one(&quot;#toolbar-1&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   330
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   331
    toolbar.plug(Y.Plugin.NodeFocusManager, {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   332
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   333
            descendants: &quot;input&quot;,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   334
            keys: { next: &quot;down:39&quot;, &#x2F;&#x2F; Right arrow
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   335
                    previous: &quot;down:37&quot; },  &#x2F;&#x2F;  Left arrow
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   336
            focusClass: &quot;focus&quot;,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   337
            circular: true
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   338
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   339
         });
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   340
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   341
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   342
    &#x2F;&#x2F;  Set the ARIA &quot;role&quot; attribute of the Node instance representing the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   343
    &#x2F;&#x2F;  toolbar to &quot;toolbar&quot; to improve the semantics of the markup for
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   344
    &#x2F;&#x2F;  users of screen readers.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   345
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   346
    toolbar.set(&quot;role&quot;, &quot;toolbar&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   347
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   348
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   349
    &#x2F;&#x2F;  Listen for the click event on each button via the use of the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   350
    &#x2F;&#x2F;  &quot;delegate&quot; method
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   351
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   352
    toolbar.delegate(&quot;click&quot;, function (event) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   353
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   354
        alert(&quot;You clicked &quot; + this.one(&quot;input&quot;).get(&quot;value&quot;));
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   355
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   356
    }, &quot;.yui3-toolbar-button&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   357
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   358
});</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   359
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   360
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   361
<h2 id="styling-focus">Styling Focus</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   362
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   363
<p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   364
To augment the browser's default styling of the focused state define a CSS
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   365
selector that adds a background color to the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   366
</p>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   367
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   368
<pre class="code prettyprint">&#x2F;*  Augment the browser&#x27;s default styling of the focus state by changing the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   369
    background color of the button when it is focused.  *&#x2F;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   370
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   371
.yui3-toolbar-button input.focus {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   372
    background-color: #B3D4FF;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   373
}</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   374
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   375
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   376
<h2 id="complete-example-source">Complete Example Source</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   377
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   378
<pre class="code prettyprint">&lt;div id=&quot;toolbar-1&quot; class=&quot;yui3-toolbar&quot;&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   379
    &lt;span id=&quot;add-btn&quot; class=&quot;yui3-toolbar-button first-child&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-add&quot; value=&quot;Add&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   380
    &lt;span id=&quot;edit-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-edit&quot; value=&quot;Edit&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   381
    &lt;span id=&quot;print-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-print&quot; value=&quot;Print&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   382
    &lt;span id=&quot;delete-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-delete&quot; value=&quot;Delete&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   383
    &lt;span id=&quot;open-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-open&quot; value=&quot;Open&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   384
    &lt;span id=&quot;save-btn&quot; class=&quot;yui3-toolbar-button&quot;&gt;&lt;span&gt;&lt;span&gt;&lt;input type=&quot;button&quot; name=&quot;btn-save&quot; value=&quot;Save&quot;&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   385
&lt;&#x2F;div&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   386
&lt;div id=&quot;out&quot;&gt;(Accessible Toolbar results here)&lt;&#x2F;div&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   387
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   388
&lt;script&gt;
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   389
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   390
    YUI().use(&quot;node-focusmanager&quot;, function (Y) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   391
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   392
        &#x2F;&#x2F;  Retrieve the Node instance representing the toolbar
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   393
        &#x2F;&#x2F;  (&lt;div id=&quot;toolbar&quot;&gt;) and call the &quot;plug&quot; method
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   394
        &#x2F;&#x2F;  passing in a reference to the Focus Manager Node Plugin.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   395
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   396
        var toolbar = Y.one(&quot;#toolbar-1&quot;),
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   397
            out     = Y.one(&quot;#out&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   398
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   399
        toolbar.plug(Y.Plugin.NodeFocusManager, {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   400
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   401
                descendants: &quot;input&quot;,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   402
                keys: { next: &quot;down:39&quot;, &#x2F;&#x2F; Right arrow
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   403
                        previous: &quot;down:37&quot; },  &#x2F;&#x2F;  Left arrow
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   404
                focusClass: &quot;focus&quot;,
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   405
                circular: true
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   406
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   407
             });
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   408
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   409
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   410
        &#x2F;&#x2F;  Set the ARIA &quot;role&quot; attribute of the Node instance representing the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   411
        &#x2F;&#x2F;  toolbar to &quot;toolbar&quot; to improve the semantics of the markup for
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   412
        &#x2F;&#x2F;  users of screen readers.
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   413
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   414
        toolbar.set(&quot;role&quot;, &quot;toolbar&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   415
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   416
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   417
        &#x2F;&#x2F;  Listen for the click event on each button via the use of the
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   418
        &#x2F;&#x2F;  &quot;delegate&quot; method
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   419
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   420
        toolbar.delegate(&quot;click&quot;, function (event) {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   421
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   422
            out.setHTML(&quot;You clicked &quot; + this.one(&quot;input&quot;).get(&quot;value&quot;));
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   423
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   424
        }, &quot;.yui3-toolbar-button&quot;);
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   425
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   426
    });
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   427
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   428
&lt;&#x2F;script&gt;</pre>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   429
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   430
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   431
            </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   432
        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   433
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   434
        <div class="yui3-u-1-4">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   435
            <div class="sidebar">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   436
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   437
                    <div id="toc" class="sidebox">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   438
                        <div class="hd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   439
                            <h2 class="no-toc">Table of Contents</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   440
                        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   441
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   442
                        <div class="bd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   443
                            <ul class="toc">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   444
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   445
<a href="#setting-up-the-html">Setting Up the HTML</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   446
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   447
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   448
<a href="#setting-up-the-css">Setting Up the CSS</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   449
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   450
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   451
<a href="#initializing-the-focus-manager">Initializing the Focus Manager</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   452
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   453
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   454
<a href="#styling-focus">Styling Focus</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   455
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   456
<li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   457
<a href="#complete-example-source">Complete Example Source</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   458
</li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   459
</ul>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   460
                        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   461
                    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   462
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   463
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   464
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   465
                    <div class="sidebox">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   466
                        <div class="hd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   467
                            <h2 class="no-toc">Examples</h2>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   468
                        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   469
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   470
                        <div class="bd">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   471
                            <ul class="examples">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   472
                                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   473
                                    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   474
                                        <li data-description="Creating an accessible toolbar using the Focus Manager Node Plugin and Node&#x27;s support for the WAI-ARIA Roles and States.">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   475
                                            <a href="node-focusmanager-toolbar.html">Accessible Toolbar</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   476
                                        </li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   477
                                    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   478
                                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   479
                                    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   480
                                        <li data-description="Creating an accessible menu button using the Focus Manager Node Plugin, Event&#x27;s delegation support and mouseenter event, along with the Overlay widget and Node&#x27;s support for the WAI-ARIA Roles and States.">
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   481
                                            <a href="node-focusmanager-button.html">Accessible Menu Button</a>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   482
                                        </li>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   483
                                    
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   484
                                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   485
                            </ul>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   486
                        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   487
                    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   488
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   489
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   490
                
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   491
            </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   492
        </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   493
    </div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   494
</div>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   495
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   496
<script src="../assets/vendor/prettify/prettify-min.js"></script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   497
<script>prettyPrint();</script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   498
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   499
<script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   500
YUI.Env.Tests = {
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   501
    examples: [],
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   502
    project: '../assets',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   503
    assets: '../assets/node-focusmanager',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   504
    name: 'node-focusmanager-toolbar',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   505
    title: 'Accessible Toolbar',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   506
    newWindow: '',
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   507
    auto:  false 
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   508
};
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   509
YUI.Env.Tests.examples.push('node-focusmanager-toolbar');
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   510
YUI.Env.Tests.examples.push('node-focusmanager-button');
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   511
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   512
</script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   513
<script src="../assets/yui/test-runner.js"></script>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   514
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   515
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   516
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   517
</body>
89ef5ed3c48b Upgrades to yui 3.10.3
gibus
parents:
diff changeset
   518
</html>