Debian Codegraph @

dijit/tests/_base/test_FocusManager.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3
4 <!-- Remove in 2.0, replaced by dijit/tests/focus.html -->
5
6 <html>
7 <head>
8 <title>dijit.focus Test</title>
9 <style type="text/css">
10 @import "../../themes/claro/document.css";
11 @import "../../themes/claro/claro.css";
12 @import "../css/dijitTests.css";
13 </style>
14
15 <script type="text/javascript" src="../../../dojo/dojo.js"
16 data-dojo-config="isDebug: true"></script>
17 <script type="text/javascript">
18 dojo.require("dijit.focus"); // dijit.focus()
19 dojo.require("dijit._base.focus"); // dijit.getFocus()
20 dojo.require("dijit._editor.selection"); // accessed by robot test
21 var savedFocus, fakeWidget;
22 dojo.ready(function(){
23 fakeWidget = { domNode: dojo.byId("save") };
24 dojo.subscribe("focusNode", function(node){ console.log("focused on " + (node?(node.id||node.tagName):"nothing"));});
25 });
26 function save(){
27 savedFocus = dijit.getFocus(fakeWidget);
28 console.debug("saved focus: ", savedFocus);
29
30 }
31 function restore(){
32 dijit.focus(savedFocus);
33 console.log("restored focus to: ", savedFocus);
34 }
35 </script>
36 </head>
37 <body style="background-color: #fff; color: black; padding: 0; margin: 0" class="claro">
38
39 <h3>Focus/Selection Save/Restore Test</h3>
40 <p>This is for testing whether focus and selection can be saved and restored by the focus manager.</p>
41 <p>
42 If you press the "Save focus" button, it should save the focus, but not the selection.
43 This is because merely pressing that button makes the focused textarea/input lose focus,
44 which also loses the selection. (We fudge things by saving the previously focused element rather
45 than the currently focused one.)
46 </p>
47 <p>
48 If you press the "Save focus/selection state after 3 seconds" button, and then focus an input/textarea
49 and select some text, it should (after three seconds) save both the focused element and the selection.
50 </p>
51 <p id="selectableText" style="color: darkred">This paragraph contains text to select for testing purposes.</p>
52 <form style="border: 2px solid blue;">
53 <input id=input1 value=tom autocomplete=off><br>
54 <input id=input2 value=jones autocomplete=off><br>
55 <textarea id=textarea autocomplete=off>hello there!</textarea><br>
56 <button id=button>push me</button>
57 </form>
58
59 <button id="save" onclick="save();">Save focus</button>
60 <button id="delay_save" onclick="console.log('set timer for func'); setTimeout(save, 3000);">Save focus/selection state after 3 seconds</button>
61 <button id="restore" onclick="restore();">Restore focus/selection state</button>
62
63 </body>
64 </html>