blob: 58c869e75ec5047ac0b498bf91a29721af665dfb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Allows moving around inputs/select by Ctrl+arrows
*
* @param object event data
*/
function onKeyDownArrowsHandler(e)
{
e = e||window.event;
var o = (e.srcElement||e.target);
if (!o) {
return;
}
if (o.tagName != "TEXTAREA" && o.tagName != "INPUT" && o.tagName != "SELECT") {
return;
}
if (navigator.userAgent.toLowerCase().indexOf('applewebkit/') != -1) {
if (e.ctrlKey || e.shiftKey || !e.altKey) {
return;
}
} else {
if (!e.ctrlKey || e.shiftKey || e.altKey) {
return;
}
}
if (!o.id) {
return;
}
var pos = o.id.split("_");
if (pos[0] != "field" || typeof pos[2] == "undefined") {
return;
}
var x = pos[2], y=pos[1];
// skip non existent fields
for (i=0; i<10; i++)
{
if (switch_movement) {
switch(e.keyCode) {
case 38:
// up
x--;
break;
case 40:
// down
x++;
break;
case 37:
// left
y--;
break;
case 39:
// right
y++;
break;
default:
return;
}
} else {
switch(e.keyCode) {
case 38:
// up
y--;
break;
case 40:
// down
y++;
break;
case 37:
// left
x--;
break;
case 39:
// right
x++;
break;
default:
return;
}
}
var id = "field_" + y + "_" + x;
var nO = document.getElementById(id);
if (!nO) {
var id = "field_" + y + "_" + x + "_0";
var nO = document.getElementById(id);
}
if (nO) {
break;
}
}
if (!nO) {
return;
}
nO.focus();
if (nO.tagName != 'SELECT') {
nO.select();
}
e.returnValue = false;
}
|