• R/O
  • SSH
  • HTTPS

traclight: Commit


Commit MetaInfo

Revision120 (tree)
Time2010-12-11 17:43:42
Authorokamototk

Log Message

support move field with up and down key.

Change Summary

Incremental Difference

--- branches/tl3_0/plugins/svn/timingandestimationplugin/timingandestimationplugin/worktime_webui.py (revision 119)
+++ branches/tl3_0/plugins/svn/timingandestimationplugin/timingandestimationplugin/worktime_webui.py (revision 120)
@@ -96,6 +96,7 @@
9696 if ticket['id']==id:
9797 ticket[e['name']]=e['value']
9898
99+ add_script(req, 'worktime/worktime.js')
99100 add_stylesheet(req, 'common/css/report.css')
100101 return 'entryworktime.html', {'tickets':tickets, 'req':req}, None
101102
--- branches/tl3_0/plugins/svn/timingandestimationplugin/timingandestimationplugin/htdocs/worktime.js (nonexistent)
+++ branches/tl3_0/plugins/svn/timingandestimationplugin/timingandestimationplugin/htdocs/worktime.js (revision 120)
@@ -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
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
--- branches/tl3_0/plugins/svn/timingandestimationplugin/timingandestimationplugin/templates/entryworktime.html (revision 119)
+++ branches/tl3_0/plugins/svn/timingandestimationplugin/timingandestimationplugin/templates/entryworktime.html (revision 120)
@@ -16,9 +16,16 @@
1616 });
1717 function moveFocus(e){
1818 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+ });
2125
26+// fname = id.substring(0,id.indexOf('_')+1);
27+// fid = parseInt(id.substring(id.indexOf('_')+1,id.length));
28+
2229 if(navigator.appName.charAt(0)=="N")
2330 kc=e.which;
2431 if(navigator.appName.charAt(0)=="M")
@@ -26,15 +33,17 @@
2633
2734 // up
2835 if(kc==38) {
29- f = document.getElementById(fname+(fid-1));
30- if (f==undefined) return ;
31- f.focus();
36+ if(current_pos-1 &gt; =0){
37+ f = ele.get(current_pos-1);
38+ f.focus();
39+ }
3240 }
3341 // down
3442 if(kc==40) {
35- f = document.getElementById(fname+(fid+1));
36- if (f==undefined) return ;
37- f.focus();
43+ if(current_pos+1 &lt; ele.length){
44+ f = ele.get(current_pos+1);
45+ f.focus();
46+ }
3847 }
3948 }
4049 document.onkeydown=moveFocus
@@ -88,7 +97,11 @@
8897 readonly="${tickets[i].billable=='false' or None}"
8998 onchange="
9099 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+}
92105 if(remained &lt;= 0){
93106 remained = 0;
94107 $('#closedummy_${tickets[i].id}').attr('style','display:show;');
Show on old repository browser