support move field with up and down key.
@@ -96,6 +96,7 @@ | ||
96 | 96 | if ticket['id']==id: |
97 | 97 | ticket[e['name']]=e['value'] |
98 | 98 | |
99 | + add_script(req, 'worktime/worktime.js') | |
99 | 100 | add_stylesheet(req, 'common/css/report.css') |
100 | 101 | return 'entryworktime.html', {'tickets':tickets, 'req':req}, None |
101 | 102 |
@@ -0,0 +1,30 @@ | ||
1 | +function moveFocus(e){ | |
2 | + id = e.target.id; | |
3 | + ele = $("input[id^='hours_']"); | |
4 | + current_pos = -1; | |
5 | + ele.each(function(i){ | |
6 | + if($(this).attr('id')==id){ | |
7 | + current_pos = i; | |
8 | + } | |
9 | + }); | |
10 | + if(current_pos==-1)return; | |
11 | + if(navigator.appName.charAt(0)=="N") | |
12 | + kc=e.which; | |
13 | + if(navigator.appName.charAt(0)=="M") | |
14 | + kc=event.keyCode; | |
15 | + // up | |
16 | + if(kc==38) { | |
17 | + if(current_pos-1>=0){ | |
18 | + f = ele.get(current_pos-1); | |
19 | + f.focus(); | |
20 | + } | |
21 | + } | |
22 | + // down | |
23 | + if(kc==40) { | |
24 | + if(current_pos+1<ele.length){ | |
25 | + f = ele.get(current_pos+1); | |
26 | + f.focus(); | |
27 | + } | |
28 | + } | |
29 | +} | |
30 | +document.onkeydown=moveFocus |
@@ -16,9 +16,16 @@ | ||
16 | 16 | }); |
17 | 17 | function moveFocus(e){ |
18 | 18 | id = e.target.id; |
19 | - fname = id.substring(0,id.indexOf('_')+1); | |
20 | - fid = parseInt(id.substring(id.indexOf('_')+1,id.length)); | |
19 | + ele = $("input[id^='hours_']"); | |
20 | + ele.each(function(i){ | |
21 | + if($(this).attr('id')==id){ | |
22 | + current_pos = i; | |
23 | + } | |
24 | + }); | |
21 | 25 | |
26 | +// fname = id.substring(0,id.indexOf('_')+1); | |
27 | +// fid = parseInt(id.substring(id.indexOf('_')+1,id.length)); | |
28 | + | |
22 | 29 | if(navigator.appName.charAt(0)=="N") |
23 | 30 | kc=e.which; |
24 | 31 | if(navigator.appName.charAt(0)=="M") |
@@ -26,15 +33,17 @@ | ||
26 | 33 | |
27 | 34 | // up |
28 | 35 | if(kc==38) { |
29 | - f = document.getElementById(fname+(fid-1)); | |
30 | - if (f==undefined) return ; | |
31 | - f.focus(); | |
36 | + if(current_pos-1 > =0){ | |
37 | + f = ele.get(current_pos-1); | |
38 | + f.focus(); | |
39 | + } | |
32 | 40 | } |
33 | 41 | // down |
34 | 42 | if(kc==40) { |
35 | - f = document.getElementById(fname+(fid+1)); | |
36 | - if (f==undefined) return ; | |
37 | - f.focus(); | |
43 | + if(current_pos+1 < ele.length){ | |
44 | + f = ele.get(current_pos+1); | |
45 | + f.focus(); | |
46 | + } | |
38 | 47 | } |
39 | 48 | } |
40 | 49 | document.onkeydown=moveFocus |
@@ -88,7 +97,11 @@ | ||
88 | 97 | readonly="${tickets[i].billable=='false' or None}" |
89 | 98 | onchange=" |
90 | 99 | remained_org = $('#remainedhours_${tickets[i].id}_old'); |
91 | -remained = parseFloat(remained_org.text())-parseFloat(this.value); | |
100 | +if(this.value!=''){ | |
101 | + remained = parseFloat(remained_org.text())-parseFloat(this.value); | |
102 | +} else { | |
103 | + remained = parseFloat(remained_org.text()); | |
104 | +} | |
92 | 105 | if(remained <= 0){ |
93 | 106 | remained = 0; |
94 | 107 | $('#closedummy_${tickets[i].id}').attr('style','display:show;'); |