Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: third_party/polymer/v0_8/components-chromium/iron-a11y-keys/iron-a11y-keys-extracted.js

Issue 1162563004: Upgrade to 1.0 and switch clients to dom-repeat where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a layout import and remove the gzipped webanimation in reproduce.sh Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1
2
3 /*
4 `iron-a11y-keys` provides a normalized interface for processing keyboard command s that pertain to [WAI-ARIA best
5 practices](http://www.w3.org/TR/wai-aria-practices/#kbd_general_binding). The el ement takes care of browser differences
6 with respect to Keyboard events and uses an expressive syntax to filter key pres ses.
7
8 Use the `keys` attribute to express what combination of keys will trigger the ev ent to fire.
9
10 Use the `target` attribute to set up event handlers on a specific node.
11 The `keys-pressed` event will fire when one of the key combinations set with the `keys` attribute is pressed.
12
13 Example:
14
15 This element will call `arrowHandler` on all arrow keys:
16
17 <iron-a11y-keys target="{{}}" keys="up down left right" on-keys-pressed="{{a rrowHandler}}"></iron-a11y-keys>
18
19 Keys Syntax:
20
21 The `keys` attribute can accepts a space seprated, `+` concatenated set of modif ier keys and some common keyboard keys.
22
23 The common keys are `a-z`, `0-9` (top row and number pad), `*` (shift 8 and numb er pad), `F1-F12`, `Page Up`, `Page
24 Down`, `Left Arrow`, `Right Arrow`, `Down Arrow`, `Up Arrow`, `Home`, `End`, `Es cape`, `Space`, `Tab`, and `Enter` keys.
25
26 The modifier keys are `Shift`, `Control`, and `Alt`.
27
28 All keys are expected to be lowercase and shortened:
29 `Left Arrow` is `left`, `Page Down` is `pagedown`, `Control` is `ctrl`, `F1` is `f1`, `Escape` is `esc` etc.
30
31 Keys Syntax Example:
32
33 Given the `keys` attribute value "ctrl+shift+f7 up pagedown esc space alt+m", th e `<iron-a11y-keys>` element will send
34 the `keys-pressed` event if any of the follow key combos are pressed: Control an d Shift and F7 keys, Up Arrow key, Page
35 Down key, Escape key, Space key, Alt and M key.
36
37 Slider Example:
38
39 The following is an example of the set of keys that fulfil the WAI-ARIA "slider" role [best
40 practices](http://www.w3.org/TR/wai-aria-practices/#slider):
41
42 <iron-a11y-keys target="{{}}" keys="left pagedown down" on-keys-pressed="{{d ecrement}}"></iron-a11y-keys>
43 <iron-a11y-keys target="{{}}" keys="right pageup up" on-keys-pressed="{{incr ement}}"></iron-a11y-keys>
44 <iron-a11y-keys target="{{}}" keys="home" on-keys-pressed="{{setMin}}"></iro n-a11y-keys>
45 <iron-a11y-keys target="{{}}" keys="end" on-keys-pressed="{{setMax}}"></iron -a11y-keys>
46
47 The `increment` function will move the slider a set amount toward the maximum va lue.
48 The `decrement` function will move the slider a set amount toward the minimum va lue.
49 The `setMin` function will move the slider to the minimum value.
50 The `setMax` function will move the slider to the maximum value.
51
52 Keys Syntax Grammar:
53
54 [EBNF](http://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_Form) Grammar o f the `keys` attribute.
55
56 modifier = "shift" | "ctrl" | "alt";
57 ascii = ? /[a-z0-9]/ ? ;
58 fnkey = ? f1 through f12 ? ;
59 arrow = "up" | "down" | "left" | "right" ;
60 key = "tab" | "esc" | "space" | "*" | "pageup" | "pagedown" | "home" | "end" | arrow | ascii | fnkey ;
61 keycombo = { modifier, "+" }, key ;
62 keys = keycombo, { " ", keycombo } ;
63
64 @demo demo/index.html
65 */
66
67
68 Polymer({
69 is: 'iron-a11y-keys',
70
71 behaviors: [
72 Polymer.IronA11yKeysBehavior
73 ],
74
75 properties: {
76 target: {
77 type: Object,
78 observer: '_targetChanged'
79 },
80
81 keys: {
82 type: String,
83 reflectToAttribute: true,
84 observer: '_keysChanged'
85 }
86 },
87
88 attached: function() {
89 if (!this.target) {
90 this.target = this.parentNode;
91 }
92 },
93
94 _targetChanged: function(target) {
95 this.keyEventTarget = target;
96 },
97
98 _keysChanged: function() {
99 this.removeOwnKeyBindings();
100 this.addOwnKeyBinding(this.keys, '_fireKeysPressed');
101 },
102
103 _fireKeysPressed: function(event) {
104 this.fire('keys-pressed', event.detail, {});
105 }
106 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698