| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | |
| 5 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 6 | |
| 7 | <title>KeyNavContainer test</title> |
| 8 | |
| 9 | <script src="boilerplate.js"></script> |
| 10 | |
| 11 | <script type="text/javascript"> |
| 12 | require([ |
| 13 | "dojo/_base/declare", "dojo/dom", "dojo/keys", "dojo/_base/lang", "dojo/on", "dojo/parser", |
| 14 | "dijit/a11yclick", "dijit/_WidgetBase", "dijit/_KeyNavContainer", |
| 15 | "dojo/domReady!" |
| 16 | ], function(declare, dom, keys, lang, on, parser, a11yclick, _WidgetBase, _KeyNavContainer){ |
| 17 | |
| 18 | declare("TestContainer", [_WidgetBase, _KeyNavContainer], { |
| 19 | postCreate: function(){ |
| 20 | this.inherited(arguments); |
| 21 | this.connectKeyNavHandlers([keys.LEFT_ARROW, keys.UP_ARROW], [keys.RIGHT_ARROW, keys.DOWN_ARROW]); |
| 22 | } |
| 23 | }); |
| 24 | |
| 25 | declare("TestContained", _WidgetBase, { |
| 26 | // _KeyNavContainer requires children to have focus() |
| 27 | focus: function(){ |
| 28 | this.domNode.focus(); |
| 29 | } |
| 30 | }); |
| 31 | |
| 32 | // For testing keyboard search |
| 33 | declare("KeyboardContainer", TestContainer, { |
| 34 | postCreate: function(){ |
| 35 | this.inherited(arguments); |
| 36 | on(this.domNode, a11yclick.click, lang.hitch(this, function(){ |
| 37 | console.log("a11yclick"); |
| 38 | dom.byId("clicks").innerHTML = dom.byId("clicks").innerHTML - -1; |
| 39 | })); |
| 40 | } |
| 41 | }); |
| 42 | |
| 43 | parser.parse(); |
| 44 | }); |
| 45 | </script> |
| 46 | </head> |
| 47 | <body> |
| 48 | <h1>_KeyNavContainer Tests</h1> |
| 49 | |
| 50 | <label for="input">focus point:</label><input id="input"/> |
| 51 | |
| 52 | <div id="keyboard" data-dojo-type="KeyboardContainer" style="border: 1px solid black;"> |
| 53 | <div data-dojo-type="TestContained" value="AL">Alabama</div> |
| 54 | <div data-dojo-type="TestContained" value="AK">Alaska</div> |
| 55 | <div data-dojo-type="TestContained" value="AZ">Arizona</div> |
| 56 | <div data-dojo-type="TestContained" value="AR">Arkansas</div> |
| 57 | <div data-dojo-type="TestContained" value="CA">California</div> |
| 58 | <div data-dojo-type="TestContained" value="NH">New Hampshire</div> |
| 59 | <div data-dojo-type="TestContained" value="NJ">New Jersey</div> |
| 60 | <div data-dojo-type="TestContained" value="NM">New Mexico</div> |
| 61 | <div data-dojo-type="TestContained" value="NY">New York</div> |
| 62 | </div> |
| 63 | |
| 64 | a11yclick events: <span id="clicks">0</span> |
| 65 | </body> |
| 66 | </html> |